From 947727681ba270256bb7772485878892ba12e4f7 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Mon, 17 Jul 2023 19:58:38 +0200 Subject: [PATCH] tools: pylint make-directive-index.py --- tools/make-directive-index.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/make-directive-index.py b/tools/make-directive-index.py index 8a2939959be..5398b452eff 100755 --- a/tools/make-directive-index.py +++ b/tools/make-directive-index.py @@ -1,12 +1,13 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: LGPL-2.1-or-later -import sys import collections import re -from xml_helper import xml_parse, xml_print, tree +import sys from copy import deepcopy +from xml_helper import tree, xml_parse, xml_print + COLOPHON = '''\ This index contains {count} entries in {sections} sections, referring to {pages} individual manual pages. @@ -101,7 +102,7 @@ def _extract_directives(directive_groups, formatting, page): formatting[name.text] = name def _make_section(template, name, directives, formatting): - varlist = template.find(".//*[@id='{}']".format(name)) + varlist = template.find(f".//*[@id='{name}']") for varname, manpages in sorted(directives.items()): entry = tree.SubElement(varlist, 'varlistentry') term = tree.SubElement(entry, 'term') @@ -161,14 +162,14 @@ def make_page(template_path, xml_files): for page in xml_files: try: _extract_directives(directive_groups, formatting, page) - except Exception: - raise ValueError("failed to process " + page) + except Exception as e: + raise ValueError("failed to process " + page) from e return _make_page(template, directive_groups, formatting) if __name__ == '__main__': with open(sys.argv[1], 'wb') as f: - template_path = sys.argv[2] - xml_files = sys.argv[3:] - xml = make_page(template_path, xml_files) - f.write(xml_print(xml)) + _template_path = sys.argv[2] + _xml_files = sys.argv[3:] + _xml = make_page(_template_path, _xml_files) + f.write(xml_print(_xml)) -- 2.47.3