abouttreesummaryrefslogcommitdiff
path: root/check_layout.py
diff options
context:
space:
mode:
Diffstat (limited to 'check_layout.py')
-rw-r--r--check_layout.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/check_layout.py b/check_layout.py
index ee1cbc9..0208a97 100644
--- a/check_layout.py
+++ b/check_layout.py
@@ -1,5 +1,5 @@
import xml.etree.ElementTree as ET
-import sys, os, glob
+import sys, os, glob, re
layout_file_name = 0
warnings = []
@@ -15,6 +15,9 @@ KEY_ATTRIBUTES = set([
"c", "nw", "ne", "sw", "se", "w", "e", "n", "s"
])
+# Keys defined in KeyValue.java
+known_keys = set()
+
def warn(msg):
global warnings
warnings.append("%s: %s" % (layout_file_name, msg))
@@ -103,6 +106,23 @@ def check_layout(layout):
if root.get("script") == None:
warn("Layout doesn't specify a script.")
+ keys_without_loc = set(( k.removeprefix("loc ") for k in keys ))
+ # Keys with a len under 3 are often composed characters
+ special_keys = set(( k for k in keys_without_loc if len(k) > 3 and ":" not in k ))
+ unknown = special_keys.difference(known_keys)
+ if len(unknown) > 0:
+ warn("Layout contains unknown keys: %s" % key_list_str(unknown))
+
+# Fill 'known_keys', which is used for some checks
+def parse_known_keys():
+ global known_keys
+ with open("srcs/juloo.keyboard2/KeyValue.java", "r") as f:
+ known_keys = set(
+ ( m.group(1) for m in re.finditer('case "([^"]+)":', f.read()) )
+ )
+
+parse_known_keys()
+
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: