From b526feb1105f53ac143f12e3c24b164053f9a23a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 19 May 2021 19:54:52 +0000 Subject: ci: use argparse for the yaml converter script --- .gitlab-ci/yaml-to-junit-xml.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to '.gitlab-ci') diff --git a/.gitlab-ci/yaml-to-junit-xml.py b/.gitlab-ci/yaml-to-junit-xml.py index b297290..4e1f8a4 100755 --- a/.gitlab-ci/yaml-to-junit-xml.py +++ b/.gitlab-ci/yaml-to-junit-xml.py @@ -4,12 +4,25 @@ # # This file is formatted with Python Black +import argparse import yaml import sys +import pathlib from xml.dom import minidom -with open(sys.argv[1]) as fd: - yml = yaml.safe_load(open(sys.argv[1])) +parser = argparse.ArgumentParser(description="Converts YAML to JUnit XML") +parser.add_argument( + "inputfile", + type=pathlib.Path, + help="The YAML output file from the keyboard layout tester", +) +args = parser.parse_args() +if not args.inputfile.exists(): + print(f"No such file: {args.inputfile}") + sys.exit(0) + +with open(args.inputfile) as fd: + yml = yaml.safe_load(fd) doc = minidom.Document() suite = doc.createElement("testsuite") -- cgit v1.2.1