From 8e5a3d8d7da469b5cef7530b1ce3f1a4b9471554 Mon Sep 17 00:00:00 2001 From: Magnus Jacobsson Date: Sun, 7 Jun 2020 18:54:30 +0200 Subject: [PATCH] Add coloring options --- ci/generate-configuration-table.py | 33 +++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/ci/generate-configuration-table.py b/ci/generate-configuration-table.py index fe418d5e5..a6f206fa2 100755 --- a/ci/generate-configuration-table.py +++ b/ci/generate-configuration-table.py @@ -19,6 +19,13 @@ def main(): parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help='Log info about what is going on') + parser.add_option('-c', '--color', action='store_const', + dest='colors', const = 'green:red', default=None, + help='Color output using default coloring. Yes is colored \ + green and No is colored red') + parser.add_option('--colors', action='store', + dest='colors', default=None, + help='Color output using specifed COLORS. The format is :') parser.add_option('-s', '--short', action='store_true', dest='short', default=False, help='Output only Yes or No') @@ -34,6 +41,28 @@ def main(): parser.print_help(file=sys.stderr) exit(1) + if opts.colors == None: + styles = { + 'Yes': '', + 'No': '', + } + else: + if opts.colors == '': + yes_color = 'green' + no_color = 'red' + else: + colors = opts.colors.split(':') + if len(colors) == 2: + yes_color, no_color = colors + else: + print('Error:', opts.colors, 'color specification is illegal', file=sys.stderr) + parser.print_help(file=sys.stderr) + exit(1) + styles = { + 'Yes': ' style="color: ' + yes_color + ';"', + 'No': ' style="color: ' + no_color + ';"', + } + table = {} table_sections = [] component_names = {} @@ -114,7 +143,9 @@ def main(): print(indent + '' + component_name + '') for platform in platforms: component_value = table[section_name][component_name][platform] - print(indent + '' + component_value + '') + short_value = re.sub('(Yes|No).*', '\\1', component_value) + color_style = styles[short_value] + print(indent + '' + component_value + '') indent = indent[:-2] print(indent + '') print(indent + ' ') -- 2.40.0