Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
16 changes: 16 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,22 @@ jobs:
test $(libwacom-list-devices --format=yaml | yq -r '.devices[] | select(.bus == "usb") | select(.vid == "0x056a") | select(.pid == "0x0358") | .name' | wc -l) -eq 1
test $(libwacom-list-devices --format=yaml | yq -r '.devices[] | select(.bus == "usb") | select(.vid == "0x056a") | select(.pid == "0x032a") | .name' | wc -l) -eq 1

####
# make sure clean_svg.py works on our layout files
clean-svg-check:
needs: build-and-dist
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: run clean-svg on all .tablet files
run: |
for tabletfile in data/*.tablet; do
./tools/clean_svg.py --ignore-missing "$tabletfile" ""
done

###
#
# tarball verification
Expand Down
28 changes: 23 additions & 5 deletions tools/clean_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#

import sys
from pathlib import Path
from argparse import ArgumentParser
from xml.etree import ElementTree as ET

Expand Down Expand Up @@ -261,7 +262,7 @@ def apply_id_and_class_from_group(group_node):
_id = group_node.attrib.get("id")
if _id is None:
return
for child in group_node.getchildren():
for child in group_node:
if child.tag == "rect" or child.tag == "circle":
if button_assigned:
continue
Expand Down Expand Up @@ -302,23 +303,40 @@ def clean_svg(root, tabletname):
if __name__ == "__main__":
parser = ArgumentParser(description="Clean SVG files for libwacom")
parser.add_argument(
"filename", nargs=1, type=str, help="SVG file to clean", metavar="FILE"
"--ignore-missing", action="store_true", 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(
"tabletname",
nargs=1,
type=str,
help="The name of the tablet",
metavar="TABLET_NAME",
)
args = parser.parse_args()

svgfile = args.filename
tabletname = args.tabletname
if args.filename.endswith(".tablet"):
import configparser
config = configparser.ConfigParser()
config.read(args.filename)
try:
svgname = config["Device"]["Layout"]
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"]


ET.register_namespace("", NAMESPACE)
try:
tree = ET.parse(args.filename[0])
tree = ET.parse(svgfile)
except Exception as e:
sys.stderr.write(str(e) + "\n")
sys.exit(1)
root = tree.getroot()
clean_svg(root, args.tabletname[0])
clean_svg(root, tabletname)
print(to_string(root))