]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
generate-bpf-delegate-configs: fix compatibility with Python 3.7
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Wed, 9 Jul 2025 08:08:34 +0000 (10:08 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 10 Jul 2025 04:30:44 +0000 (13:30 +0900)
- Operator ":=" requires Python 3.8 or newer.
- list[str] requires Python 3.9 or newer.

Follow-up for ea9826eb946d57aaba7e6bfa2d6b120136c6b20f

src/basic/generate-bpf-delegate-configs.py

index 200c913b8a8264d976a88cfc6ea073f24ae036c0..4444282b4b536637a13b51e2379c965e0444aac7 100755 (executable)
@@ -7,6 +7,7 @@
 
 import re
 import sys
+import typing
 
 
 def print_usage_and_exit() -> None:
@@ -26,7 +27,7 @@ if output not in ['code', 'doc']:
 
 with open(header) as file:
     inEnum = False
-    enumValues: list[str] = []
+    enumValues: typing.List[str] = []
     enumName = ''
 
     if output == 'doc':
@@ -67,10 +68,12 @@ with open(header) as file:
                 match = re.fullmatch(r'(\w+)\b,', line)
                 if match and len(match.groups()) > 0 and not match[1].startswith('__'):
                     enumValues.append(match[1])
-        elif match := re.match(r'^\s*enum\s+bpf_(cmd|map_type|prog_type|attach_type)+\s*{', line):
-            # Start of a new enum
-            inEnum = True
-            enumName = 'bpf_delegate_' + match[1]
+        else:
+            match = re.match(r'^\s*enum\s+bpf_(cmd|map_type|prog_type|attach_type)+\s*{', line)
+            if match:
+                # Start of a new enum
+                inEnum = True
+                enumName = 'bpf_delegate_' + match[1]
 
     if output == 'doc':
         print('</para>')