abouttreesummaryrefslogcommitdiff
path: root/check_layout.py
diff options
context:
space:
mode:
authorJules Aguillon2024-01-10 23:00:40 +0100
committerJules Aguillon2024-01-10 23:00:40 +0100
commit6725d3057bc64a317d3d6ea38def15553ba01f0c (patch)
tree819e3043b994933a44b2fe2552b1fc703756fd32 /check_layout.py
parentcf9fd3a0db220c997baf4057e06233133638a536 (diff)
downloadunexpected-keyboard-6725d3057bc64a317d3d6ea38def15553ba01f0c.tar.gz
unexpected-keyboard-6725d3057bc64a317d3d6ea38def15553ba01f0c.zip
check_layout: Stronger bottom row key check
Diffstat (limited to 'check_layout.py')
-rw-r--r--check_layout.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/check_layout.py b/check_layout.py
index 23481ad..067098d 100644
--- a/check_layout.py
+++ b/check_layout.py
@@ -34,6 +34,15 @@ def unexpected_keys(keys, symbols, msg):
if len(unexpected) > 0:
warn("%s, unexpected: %s" % (msg, key_list_str(unexpected)))
+# Write to [keys] and [dup].
+def parse_row_from_et(row, keys, dup):
+ for key in row:
+ for attr in key.keys():
+ if attr.startswith("key"):
+ k = key.get(attr).removeprefix("\\")
+ if k in keys: dup.add(k)
+ keys.add(k)
+
def parse_layout(fname):
keys = set()
dup = set()
@@ -41,12 +50,16 @@ def parse_layout(fname):
if root.tag != "keyboard":
return None
for row in root:
- for key in row:
- for attr in key.keys():
- if attr.startswith("key"):
- k = key.get(attr).removeprefix("\\")
- if k in keys: dup.add(k)
- keys.add(k)
+ parse_row_from_et(row, keys, dup)
+ return root, keys, dup
+
+def parse_row(fname):
+ keys = set()
+ dup = set()
+ root = ET.parse(fname).getroot()
+ if root.tag != "row":
+ return None
+ parse_row_from_et(root, keys, dup)
return root, keys, dup
def check_layout(layout):
@@ -68,11 +81,7 @@ def check_layout(layout):
"Layout contains function keys")
unexpected_keys(keys, [""], "Layout contains empty strings")
- bottom_row_keys = [
- "ctrl", "fn", "switch_numeric", "change_method", "switch_emoji",
- "config", "switch_forward", "switch_backward", "enter", "action",
- "left", "up", "right", "down", "space"
- ]
+ _, bottom_row_keys, _ = parse_row("res/xml/bottom_row.xml")
if root.get("bottom_row") == "false":
missing_required(keys, bottom_row_keys,