diff options
| author | Jules Aguillon | 2025-02-04 17:17:46 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2025-02-04 17:17:46 +0100 |
| commit | aaf0a9a24999769a0bba9ec45968368ff0019012 (patch) | |
| tree | 9e6d45a68aad341d05d814798682ef14c8772975 /check_layout.py | |
| parent | ae9c2fa626309115d7cface25b656ecee5936fab (diff) | |
| download | unexpected-keyboard-aaf0a9a24999769a0bba9ec45968368ff0019012.tar.gz unexpected-keyboard-aaf0a9a24999769a0bba9ec45968368ff0019012.zip | |
Improve the check_layout CI and output
Change the format of check_layout.output to avoid adding any logs for
layouts that do not trigger any warning.
Fix the check_layout CI, which was broken since check_layout.py was
changed to take arguments.
Diffstat (limited to 'check_layout.py')
| -rw-r--r-- | check_layout.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/check_layout.py b/check_layout.py index 500b10b..ee1cbc9 100644 --- a/check_layout.py +++ b/check_layout.py @@ -1,7 +1,8 @@ import xml.etree.ElementTree as ET -import sys, os +import sys, os, glob -warning_count = 0 +layout_file_name = 0 +warnings = [] KNOWN_NOT_LAYOUT = set([ "number_row", "numpad", "pin", @@ -15,9 +16,8 @@ KEY_ATTRIBUTES = set([ ]) def warn(msg): - global warning_count - print(msg) - warning_count += 1 + global warnings + warnings.append("%s: %s" % (layout_file_name, msg)) def key_list_str(keys): return ", ".join(sorted(list(keys))) @@ -103,15 +103,17 @@ def check_layout(layout): if root.get("script") == None: warn("Layout doesn't specify a script.") -for fname in sorted(sys.argv[1:]): +for fname in sorted(glob.glob("srcs/layouts/*.xml")): layout_id, _ = os.path.splitext(os.path.basename(fname)) if layout_id in KNOWN_NOT_LAYOUT: continue + layout_file_name = layout_id layout = parse_layout(fname) if layout == None: - print("Not a layout file: %s" % layout_id) + warn("Not a layout file") else: - print("# %s" % layout_id) - warning_count = 0 check_layout(layout) - print("%d warnings" % warning_count) + +with open("check_layout.output", "w") as out: + for w in warnings: + print(w, file=out) |
