]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test/parse_hwdb: wrap Or inside an And in a Group
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 16 Oct 2025 12:45:20 +0000 (14:45 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 16 Oct 2025 17:09:37 +0000 (18:09 +0100)
I now get a warning like this with python3-pyparsing-3.1.2-8.fc42:

hwdb.d/parse_hwdb.py:208: UserWarning: warn_multiple_tokens_in_named_alternation:
  setting results name 'VALUE' on Or expression will return a list of all parsed
  tokens in an And alternative, in prior versions only the first token was returned;
  enclose contained argument in Group
('!' ^ (Optional('!') - Word(alphanums + '_')))('VALUE')

hwdb.d/parse_hwdb.py

index 9a599e735c362b7f2eeea614f4cec270e3895103..768bd064d03d14d60cb68e6dfd9e5accea8fe333 100755 (executable)
@@ -205,7 +205,7 @@ def property_grammar():
                    for name, val in props]
     kbd_props = [Regex(r'KEYBOARD_KEY_[0-9a-f]+')('NAME')
                  - Suppress('=') -
-                 ('!' ^ (Optional('!') - Word(alphanums + '_')))('VALUE')
+                 Group('!' ^ (Optional('!') - Word(alphanums + '_')))('VALUE')
                 ]
     abs_props = [Regex(r'EVDEV_ABS_[0-9a-f]{2}')('NAME')
                  - Suppress('=') -