From ff19ac58e14e319afbc33aa485af4b4370b2af2e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 17 Feb 2021 09:56:53 +1000 Subject: scripts: use a named pattern for the hexcode check in comments Signed-off-by: Peter Hutterer --- scripts/keysym-generator.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'scripts') 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[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: -- cgit v1.2.3