diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2022-09-23 15:52:30 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2022-09-27 11:15:51 -0400 |
commit | 195aae6a8413790210e081149a8f8b9ba494b94e (patch) | |
tree | 1a7837a7ccf2bd7be54e918a925fcf3f7b9071c0 | |
parent | 4fce954f9798f5872f110a93317d945b3496cc0e (diff) | |
download | meson-195aae6a8413790210e081149a8f8b9ba494b94e.zip meson-195aae6a8413790210e081149a8f8b9ba494b94e.tar.gz meson-195aae6a8413790210e081149a8f8b9ba494b94e.tar.bz2 |
mconf: Do not print None for empty choices
-rw-r--r-- | mesonbuild/mconf.py | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/mesonbuild/mconf.py b/mesonbuild/mconf.py index ef176d7..54eacef 100644 --- a/mesonbuild/mconf.py +++ b/mesonbuild/mconf.py @@ -39,11 +39,14 @@ def add_arguments(parser: 'argparse.ArgumentParser') -> None: parser.add_argument('--no-pager', action='store_false', dest='pager', help='Do not redirect output to a pager') -def make_lower_case(val: T.Any) -> T.Union[str, T.List[T.Any]]: # T.Any because of recursion... +def stringify(val: T.Any) -> T.Union[str, T.List[T.Any]]: # T.Any because of recursion... if isinstance(val, bool): return str(val).lower() elif isinstance(val, list): - return [make_lower_case(i) for i in val] + s = ', '.join(stringify(i) for i in val) + return f'[{s}]' + elif val is None: + return '' else: return str(val) @@ -166,16 +169,8 @@ class Conf: self.descr_col.append(descr) def add_option(self, name, descr, value, choices): - if isinstance(value, list): - value = '[{}]'.format(', '.join(make_lower_case(value))) - else: - value = make_lower_case(value) - - if isinstance(choices, list): - choices = '[{}]'.format(', '.join(make_lower_case(choices))) - else: - choices = make_lower_case(choices) - + value = stringify(value) + choices = stringify(choices) self._add_line(mlog.green(name), mlog.yellow(value), mlog.blue(choices), descr) def add_title(self, title): |