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 ' \
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 = {}
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()