- _log_file = None
- _json_file = None
- _vpp = None
-
- try:
- opts, _ = getopt.getopt(argv, "hi:o:v:", ["help"])
- except getopt.GetoptError:
- print_help()
- sys.exit(1)
-
- for opt, arg in opts:
- if opt in ('-h', "--help"):
- print_help()
- sys.exit()
- elif opt == '-i':
- _log_file = arg
- elif opt == '-o':
- _json_file = arg
- elif opt == '-v':
- _vpp = arg
-
- if _log_file is None or _json_file is None or _vpp is None:
- print_help()
- sys.exit(1)
-
- try:
- with open(_log_file, 'r') as input_file:
- with open(_json_file, 'w') as output_file:
- out = parse_tests(input_file, _vpp)
- json.dump(out, fp=output_file, sort_keys=True,
- indent=4, separators=(',', ': '))
- except IOError as ex_error:
- print_error(str(ex_error))
- sys.exit(1)
+ args = parse_args()
+
+ root = parse_tests(args)
+ ET.ElementTree.write(ET.ElementTree(root), args.output)