]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tools: pylint list-discoverable-partitions.py
authorFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 9 Aug 2023 19:43:08 +0000 (21:43 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 10 Aug 2023 16:13:29 +0000 (18:13 +0200)
tools/list-discoverable-partitions.py

index 8376a7cdebb2363082abf18764fed39eb61a30a8..a19bf1d6e2ee7ad1887f5492b0fa9c5e73e2777f 100644 (file)
@@ -5,7 +5,7 @@ import re
 import sys
 import uuid
 
-HEADER = f'''\
+HEADER = '''\
 | Name | Partition Type UUID | Allowed File Systems | Explanation |
 |------|---------------------|----------------------|-------------|
 '''
@@ -149,21 +149,21 @@ def extract(file):
 
         name = line.split()[1]
         if m2 := re.match(r'^(ROOT|USR)_([A-Z0-9]+|X86_64|PPC64_LE|MIPS_LE|MIPS64_LE)(|_VERITY|_VERITY_SIG)\s+SD_ID128_MAKE\((.*)\)', m.group(1)):
-            type, arch, suffix, u = m2.groups()
+            ptype, arch, suffix, u = m2.groups()
             u = uuid.UUID(u.replace(',', ''))
             assert arch in ARCHITECTURES, f'{arch} not in f{ARCHITECTURES}'
-            type = f'{type}{suffix}'
-            assert type in TYPES
+            ptype = f'{type}{suffix}'
+            assert ptype in TYPES
 
-            yield name, type, arch, u
+            yield name, ptype, arch, u
 
         elif m2 := re.match(r'(\w+)\s+SD_ID128_MAKE\((.*)\)', m.group(1)):
-            type, u = m2.groups()
+            ptype, u = m2.groups()
             u = uuid.UUID(u.replace(',', ''))
-            yield name, type, None, u
+            yield name, ptype, None, u
 
         else:
-            raise Exception(f'Failed to match: {m.group(1)}')
+            raise ValueError(f'Failed to match: {m.group(1)}')
 
 def generate(defines):
     prevtype = None
@@ -172,21 +172,21 @@ def generate(defines):
 
     uuids = set()
 
-    for name, type, arch, uuid in defines:
-        tdesc = TYPES[type]
+    for name, ptype, arch, puuid in defines:
+        tdesc = TYPES[ptype]
         adesc = '' if arch is None else f' ({ARCHITECTURES[arch]})'
 
         # Let's make sure that we didn't select&paste the same value twice
-        assert uuid not in uuids
-        uuids.add(uuid)
+        assert puuid not in uuids
+        uuids.add(puuid)
 
-        if type != prevtype:
-            prevtype = type
-            morea, moreb = DESCRIPTIONS[type]
+        if ptype != prevtype:
+            prevtype = ptype
+            morea, moreb = DESCRIPTIONS[ptype]
         else:
             morea = moreb = 'ditto'
 
-        print(f'| _{tdesc}{adesc}_ | `{uuid}` `{name}` | {morea} | {moreb} |')
+        print(f'| _{tdesc}{adesc}_ | `{puuid}` `{name}` | {morea} | {moreb} |')
 
 if __name__ == '__main__':
     known = extract(sys.stdin)