make-man-index: apply "ruff format"

This commit is contained in:
Yu Watanabe
2026-05-18 02:44:47 +09:00
parent 8b24db05d4
commit 3675924f5b
+6 -1
View File
@@ -49,6 +49,7 @@ def check_id(page, t):
if not re.search('/' + page_id + '[.]', page.translate(str.maketrans('@', '_'))): if not re.search('/' + page_id + '[.]', page.translate(str.maketrans('@', '_'))):
raise ValueError(f"id='{page_id}' is not the same as page name '{page}'") raise ValueError(f"id='{page_id}' is not the same as page name '{page}'")
def make_index(pages): def make_index(pages):
index = collections.defaultdict(list) index = collections.defaultdict(list)
for p in pages: for p in pages:
@@ -63,6 +64,7 @@ def make_index(pages):
index[f.text[0].upper()].append(infos) index[f.text[0].upper()].append(infos)
return index return index
def add_letter(template, letter, pages): def add_letter(template, letter, pages):
refsect1 = tree.SubElement(template, 'refsect1') refsect1 = tree.SubElement(template, 'refsect1')
title = tree.SubElement(refsect1, 'title') title = tree.SubElement(refsect1, 'title')
@@ -77,10 +79,11 @@ def add_letter(template, letter, pages):
d = tree.SubElement(b, 'manvolnum') d = tree.SubElement(b, 'manvolnum')
d.text = section d.text = section
b.tail = MDASH + purpose # + ' (' + p + ')' b.tail = MDASH + purpose # + ' (' + p + ')'
tree.SubElement(para, 'sbr') tree.SubElement(para, 'sbr')
def add_summary(template, indexpages): def add_summary(template, indexpages):
count = 0 count = 0
pages = set() pages = set()
@@ -96,6 +99,7 @@ def add_summary(template, indexpages):
para = template.find(".//para[@id='counts']") para = template.find(".//para[@id='counts']")
para.text = COUNTS.format(count=count, pages=len(pages)) para.text = COUNTS.format(count=count, pages=len(pages))
def make_page(*xml_files): def make_page(*xml_files):
template = tree.fromstring(TEMPLATE) template = tree.fromstring(TEMPLATE)
index = make_index(xml_files) index = make_index(xml_files)
@@ -107,6 +111,7 @@ def make_page(*xml_files):
return template return template
if __name__ == '__main__': if __name__ == '__main__':
with open(sys.argv[1], 'wb') as file: with open(sys.argv[1], 'wb') as file:
file.write(xml_print(make_page(*sys.argv[2:]))) file.write(xml_print(make_page(*sys.argv[2:])))