abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorJules Aguillon2023-08-06 20:09:53 +0200
committerJules Aguillon2023-08-06 20:09:53 +0200
commiteeae964ae618125e2f12f5133faa41dca6e6b2e6 (patch)
treee8ad1b7f85d39bd4de19ee49568e28d2ed3746a0
parent8d7b3efeb1f1685aac37c59145e0752e6b13e59b (diff)
downloadunexpected-keyboard-eeae964ae618125e2f12f5133faa41dca6e6b2e6.tar.gz
unexpected-keyboard-eeae964ae618125e2f12f5133faa41dca6e6b2e6.zip
check_layout: Warn about duplicate keys
-rw-r--r--check_layout.output15
-rw-r--r--check_layout.py11
2 files changed, 18 insertions, 8 deletions
diff --git a/check_layout.output b/check_layout.output
index dc9c42d..61b0a36 100644
--- a/check_layout.output
+++ b/check_layout.output
@@ -6,8 +6,9 @@ Layout doesn't define some important keys, missing: f11_placeholder, f12_placeho
Layout includes some ASCII punctuation but not all, missing: ", %, ', +, ,, ., :, ;, <, =, >, ?, `, |, ~
1 warnings
# res/xml/arab_pc_ir.xml
+Duplicate keys: (, )
Layout includes some ASCII punctuation but not all, missing: ", %, ', ,, /, ;, <, =, >, ?, [, \, ], `, {, |, }
-1 warnings
+2 warnings
# res/xml/arab_pc.xml
Layout includes some ASCII punctuation but not all, missing: !, ', +, ;, ?, \, |
1 warnings
@@ -33,11 +34,13 @@ Layout includes some ASCII punctuation but not all, missing: #, $, %, &, ', (, )
Layout doesn't define some important keys, missing: f11_placeholder, f12_placeholder
2 warnings
# res/xml/deva_inscript.xml
+Duplicate keys: , ред
Layout includes some ASCII punctuation but not all, missing: ", $, ', ^, _, `, |
Layout doesn't define some important keys, missing: f11_placeholder, f12_placeholder
-2 warnings
+3 warnings
# res/xml/grek_qwerty.xml
-0 warnings
+Duplicate keys: ;
+1 warnings
# res/xml/hang_dubeolsik_kr.xml
0 warnings
# res/xml/hebr_1_il.xml
@@ -57,8 +60,9 @@ Layout redefines the bottom row but some important keys are missing, missing: sw
# res/xml/latn_dvorak.xml
0 warnings
# res/xml/latn_neo2.xml
+Duplicate keys: -
Layout redefines the bottom row but some important keys are missing, missing: switch_forward
-1 warnings
+2 warnings
# res/xml/latn_qwerty_br.xml
0 warnings
# res/xml/latn_qwerty_es.xml
@@ -74,7 +78,8 @@ Layout redefines the bottom row but some important keys are missing, missing: sw
# res/xml/latn_qwerty_ro.xml
0 warnings
# res/xml/latn_qwerty_se.xml
-0 warnings
+Duplicate keys: !, ', ,, -, ., ?
+1 warnings
# res/xml/latn_qwerty_tr.xml
Layout doesn't define some important keys, missing: f11_placeholder, f12_placeholder
1 warnings
diff --git a/check_layout.py b/check_layout.py
index e5e14dc..0741ffa 100644
--- a/check_layout.py
+++ b/check_layout.py
@@ -36,17 +36,22 @@ def unexpected_keys(keys, symbols, msg):
def parse_layout(fname):
keys = set()
+ dup = set()
root = ET.parse(fname).getroot()
if root.tag != "keyboard":
return None
for row in root:
for key in row:
for attr in key.keys():
- keys.add(key.get(attr).removeprefix("\\"))
- return root, keys
+ if attr.startswith("key"):
+ k = key.get(attr).removeprefix("\\")
+ if k in keys: dup.add(k)
+ keys.add(k)
+ return root, keys, dup
def check_layout(layout):
- root, keys = layout
+ root, keys, dup = layout
+ if len(dup) > 0: warn("Duplicate keys: " + key_list_str(dup))
missing_some_of(keys, "~!@#$%^&*(){}`[]=\\-_;:/.,?<>'\"+|", "ASCII punctuation")
missing_some_of(keys, "0123456789", "digits")
missing_required(keys,