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