]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
update-man-rules: apply "ruff format"
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 19 Feb 2026 17:12:28 +0000 (02:12 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 17 May 2026 17:44:47 +0000 (02:44 +0900)
tools/update-man-rules.py

index 2ac8dae56042c88700de4d15ce1188f4c28d44c6..bc233aba9483f5e21bfc5eac7d4ab7a049f84963 100755 (executable)
@@ -13,6 +13,7 @@ from xml_helper import xml_parse
 def man(page, number):
     return f'{page}.{number}'
 
+
 def add_rules(rules, name):
     xml = xml_parse(name)
     # print('parsing {}'.format(name), file=sys.stderr)
@@ -28,26 +29,28 @@ def add_rules(rules, name):
     if title != refnames[0].text:
         raise ValueError('refmeta and refnamediv disagree: ' + name)
     for refname in refnames:
-        assert all(refname not in group
-                   for group in rules.values()), "duplicate page name"
+        assert all(refname not in group for group in rules.values()), 'duplicate page name'
         alias = man(refname.text, number)
         rulegroup[alias] = target
         # print('{} => {} [{}]'.format(alias, target, conditional), file=sys.stderr)
 
+
 def create_rules(xml_files):
-    " {conditional => {alias-name => source-name}} "
+    "{conditional => {alias-name => source-name}}"
     rules = collections.defaultdict(dict)
     for name in xml_files:
         try:
             add_rules(rules, name)
         except Exception:
-            print("Failed to process", name, file=sys.stderr)
+            print('Failed to process', name, file=sys.stderr)
             raise
     return rules
 
+
 def mjoin(files):
     return ' \\\n\t'.join(sorted(files) or '#')
 
+
 MESON_HEADER = '''\
 # Do not edit. Generated by update-man-rules.py.
 # Update with:
@@ -59,6 +62,7 @@ MESON_FOOTER = '''\
 # Really, do not edit.
 '''
 
+
 def make_mesonfile(rules, _dist_files):
     # reformat rules as
     # grouped = [ [name, section, [alias...], condition], ...]
@@ -72,10 +76,13 @@ def make_mesonfile(rules, _dist_files):
             if name != alias:
                 group.append(alias)
 
-    lines = [ [p[0][:-2], p[0][-1], sorted(a[:-2] for a in aliases), p[1]]
-              for p, aliases in sorted(grouped.items()) ]
+    lines = [
+        [p[0][:-2], p[0][-1], sorted(a[:-2] for a in aliases), p[1]]
+        for p, aliases in sorted(grouped.items())
+    ]
     return '\n'.join((MESON_HEADER, pprint.pformat(lines)[1:-1], MESON_FOOTER))
 
+
 def main():
     source_glob = sys.argv[1]
     target = Path(sys.argv[2])
@@ -86,7 +93,7 @@ def main():
                      'standard-conf.xml',
                      'systemd.directives.xml',
                      'systemd.index.xml',
-                     'directives-template.xml'})
+                     'directives-template.xml'})  # fmt: skip
 
     rules = create_rules(pages)
     dist_files = (Path(p).name for p in pages)
@@ -96,5 +103,6 @@ def main():
     tmp.write_text(text)
     tmp.rename(target)
 
+
 if __name__ == '__main__':
     main()