diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5551d0e0..b0fc1d76 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -212,7 +212,7 @@ jobs: run: | for tabletfile in data/*.tablet; do echo "Checking $tabletfile" - ./tools/clean_svg.py --ignore-missing "$tabletfile" "" + ./tools/clean_svg.py --ignore-missing "$tabletfile" done ### diff --git a/tools/clean_svg.py b/tools/clean_svg.py index 544311c5..1163b3d2 100755 --- a/tools/clean_svg.py +++ b/tools/clean_svg.py @@ -317,11 +317,17 @@ def clean_svg(root, tabletname): default=False, help="Ignore .tablet files without a Layout", ) - parser.add_argument("filename", type=str, help="SVG file to clean", metavar="FILE") + parser.add_argument( + "filename", + type=str, + help="SVG file to clean or .tablet file with a Layout=xyz.svg line", + metavar="FILE", + ) parser.add_argument( "tabletname", type=str, - help="The name of the tablet", + nargs="?", + help="The name of the tablet, can be omitted if FILE is a .tablet file", metavar="TABLET_NAME", ) args = parser.parse_args() @@ -338,6 +344,8 @@ def clean_svg(root, tabletname): config.read(args.filename) try: svgname = config["Device"]["Layout"] + if not svgname: + raise KeyError("Empty layout line") except KeyError: print( f"{args.filename} does not specify a layout, skipping", file=sys.stderr @@ -345,6 +353,8 @@ def clean_svg(root, tabletname): sys.exit(0 if args.ignore_missing else 77) svgfile = Path(args.filename).parent / "layouts" / svgname tabletname = config["Device"]["Name"] + else: + assert tabletname, "Argument TABLET_NAME must be provided for SVG files" ET.register_namespace("", NAMESPACE) try: