From c4bc0c33670f5ad9992573733313e69cf5cc1262 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 11 Nov 2024 10:04:29 +1000 Subject: [PATCH 1/2] tools/clean-svg: make the tablet name argument optional If we're passing in a .tablet file we don't need the tablet name argument --- .github/workflows/main.yml | 2 +- tools/clean_svg.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) 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..f5d388a2 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() @@ -345,6 +351,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: From 3a3725df047b1b6357437948d38ded6be7a1a201 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 11 Nov 2024 10:05:44 +1000 Subject: [PATCH 2/2] tools/clean-svg: ignore an empty Layout= line Closes #818 --- tools/clean_svg.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/clean_svg.py b/tools/clean_svg.py index f5d388a2..1163b3d2 100755 --- a/tools/clean_svg.py +++ b/tools/clean_svg.py @@ -344,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