Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore empty Layout in clean-svg.py #833

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

###
Expand Down
14 changes: 12 additions & 2 deletions tools/clean_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -338,13 +344,17 @@ 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
)
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:
Expand Down