Skip to content

Commit cbb6c14

Browse files
committed
Decrease readability
1 parent c782058 commit cbb6c14

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

Doc/tools/check-html-ids.py

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
import re
1010

1111

12-
IGNORED_ID_RE = re.compile(r"""
12+
IGNORED_ID_RE = re.compile(
13+
r"""
1314
index-\d+
1415
| id\d+
1516
| [_a-z]+_\d+
16-
""", re.VERBOSE)
17+
""",
18+
re.VERBOSE,
19+
)
1720

1821

1922
class IDGatherer(html.parser.HTMLParser):
@@ -82,7 +85,8 @@ def do_check(baseline, checked, excluded, *, verbose_print):
8285
missing_ids = set(baseline_ids) - set(checked_ids)
8386
if missing_ids:
8487
missing_ids = {
85-
a for a in missing_ids
88+
a
89+
for a in missing_ids
8690
if not IGNORED_ID_RE.fullmatch(a)
8791
and (name, a) not in excluded
8892
}
@@ -97,38 +101,43 @@ def do_check(baseline, checked, excluded, *, verbose_print):
97101
def main(argv):
98102
parser = argparse.ArgumentParser()
99103
parser.add_argument(
100-
'-v', '--verbose', action='store_true',
101-
help='print out more information')
104+
'-v',
105+
'--verbose',
106+
action='store_true',
107+
help='print out more information',
108+
)
102109
subparsers = parser.add_subparsers(dest='command', required=True)
103110

104111
collect = subparsers.add_parser(
105-
'collect',
106-
help='collect IDs from a set of HTML files')
112+
'collect', help='collect IDs from a set of HTML files'
113+
)
107114
collect.add_argument(
108-
'htmldir', type=Path,
109-
help='directory with HTML documentation')
115+
'htmldir', type=Path, help='directory with HTML documentation'
116+
)
110117
collect.add_argument(
111-
'-o', '--outfile',
112-
help='File to save the result in; default <htmldir>/html-ids.json.gz')
118+
'-o',
119+
'--outfile',
120+
help='File to save the result in; default <htmldir>/html-ids.json.gz',
121+
)
113122

114-
check = subparsers.add_parser(
115-
'check',
116-
help='check two archives of IDs')
123+
check = subparsers.add_parser('check', help='check two archives of IDs')
117124
check.add_argument(
118-
'baseline_file', type=Path,
119-
help='file with baseline IDs')
125+
'baseline_file', type=Path, help='file with baseline IDs'
126+
)
127+
check.add_argument('checked_file', type=Path, help='file with checked IDs')
120128
check.add_argument(
121-
'checked_file', type=Path,
122-
help='file with checked IDs')
123-
check.add_argument(
124-
'-x', '--exclude-file', type=Path,
125-
help='file with IDs to exclude from the check')
129+
'-x',
130+
'--exclude-file',
131+
type=Path,
132+
help='file with IDs to exclude from the check',
133+
)
126134

127135
args = parser.parse_args(argv[1:])
128136

129137
if args.verbose:
130138
verbose_print = functools.partial(print, file=sys.stderr)
131139
else:
140+
132141
def verbose_print(*args, **kwargs):
133142
"""do nothing"""
134143

@@ -162,7 +171,8 @@ def verbose_print(*args, **kwargs):
162171
'The above HTML IDs were removed from the documentation, '
163172
+ 'resulting in broken links. Please add them back.',
164173
sep='\n',
165-
file=sys.stderr)
174+
file=sys.stderr,
175+
)
166176
if args.exclude_file:
167177
print(f'Alternatively, add them to {args.exclude_file}.')
168178

0 commit comments

Comments
 (0)