]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
check-os-release.py compatible with Python < 3.8
authorDavid Jaša <jasa.david@gmail.com>
Tue, 23 Aug 2022 21:58:09 +0000 (23:58 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 24 Aug 2022 03:08:17 +0000 (12:08 +0900)
The ":=" operator was only added in Python 3.8 so splitting the line with it into two makes check-os-release.py actually fulfill its claim of working with any python version.

man/check-os-release.py

index 91a5494b4a1835a687d67f136dff0bbc4adaf21b..1a57c7a20d0eee80d2a8d196282b88a90b55c9b0 100644 (file)
@@ -17,7 +17,8 @@ def read_os_release():
         line = line.rstrip()
         if not line or line.startswith('#'):
             continue
-        if m := re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line):
+        m = re.match(r'([A-Z][A-Z_0-9]+)=(.*)', line)
+        if m:
             name, val = m.groups()
             if val and val[0] in '"\'':
                 val = ast.literal_eval(val)