summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2021-02-17 09:56:53 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2021-02-17 10:18:19 +1000
commitff19ac58e14e319afbc33aa485af4b4370b2af2e (patch)
treef856eef554e8c35f947fb801b15c0ebcd083d7ff
parent08549dc8580f498899e82846bebea40f70b8a443 (diff)
scripts: use a named pattern for the hexcode check in comments
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rwxr-xr-xscripts/keysym-generator.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/scripts/keysym-generator.py b/scripts/keysym-generator.py
index 6bcde61..c21ba0e 100755
--- a/scripts/keysym-generator.py
+++ b/scripts/keysym-generator.py
@@ -158,7 +158,7 @@ def verify(ns):
)
# This is the comment pattern we expect
expected_comment_pattern = re.compile(
- r"/\* Use: \w+\t+_EVDEVK\(0x([0-9A-F]{3})\)\t+ (v[2-6]\.[0-9]+(\.[0-9]+)?)? +KEY_\w+ \*/"
+ r"/\* Use: \w+\t+_EVDEVK\(0x(?P<value>[0-9A-F]{3})\)\t+ (v[2-6]\.[0-9]+(\.[0-9]+)?)? +KEY_\w+ \*/"
)
# Some patterns to spot specific errors, just so we can print useful errors
@@ -206,12 +206,11 @@ def verify(ns):
if not re.match(define, line):
match = re.match(expected_comment_pattern, line)
if match:
- if match.group(1) != match.group(1).upper():
- error(
- f"Hex code 0x{match.group(1)} must be uppercase", line
- )
- if match.group(1):
- keycode = int(match.group(1), 16)
+ hexcode = match.group("value")
+ if hexcode != hexcode.upper():
+ error(f"Hex code 0x{hexcode} must be uppercase", line)
+ if hexcode:
+ keycode = int(hexcode, 16)
if keycode < last_keycode:
error("Keycode must be ascending", line)
if keycode == last_keycode: