From: Magnus Jacobsson Date: Sun, 7 Jun 2020 14:38:20 +0000 (+0200) Subject: Add JSON output X-Git-Tag: 2.44.1~11^2^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa1017a7a48ee20f137dbc72d45635eeb108ad8b;p=graphviz Add JSON output --- diff --git a/ci/generate-configuration-table.py b/ci/generate-configuration-table.py index 6afcf0d03..c8954fd1b 100755 --- a/ci/generate-configuration-table.py +++ b/ci/generate-configuration-table.py @@ -3,8 +3,13 @@ from optparse import OptionParser import os +import json +import sys def main(): + supported_output_formats = [ + 'JSON', + ] parser = OptionParser(usage='usage: %prog [options] files...') parser.description = 'Generate a table of the Graphviz compile ' \ 'configuration for different platforms from files generated by the ' \ @@ -12,9 +17,18 @@ 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('--output-format', action='store', + dest='output_format', default='JSON', + help='Set output format. Supported formats are ' + + ' and '.join(supported_output_formats)) (opts, args) = parser.parse_args() + if opts.output_format.upper() not in supported_output_formats: + print('Error:', opts.output_format, 'output format is not supported', file=sys.stderr) + parser.print_help(file=sys.stderr) + exit(1) + table = {} table_sections = [] component_names = {} @@ -45,6 +59,9 @@ def main(): component_names[section_name].append(component_name) table[section_name][component_name][platform] = component_value + if opts.output_format.upper() == 'JSON': + print(json.dumps(table, indent=4)) + # Python trick to get a main routine if __name__ == "__main__": main()