Skip to content

Commit f1184d7

Browse files
committed
ENH: Display additional dict when running in brief mode or verbose >= 0
1 parent e11d4ac commit f1184d7

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

codespell.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,12 @@ def parse_args():
332332
return args
333333

334334

335-
def add_dict(enchant_dict, filename):
335+
def add_dict(enchant_dict, filename, verbose=False):
336336
"""Update ``enchant_dict`` spell checking dictionary with the words listed
337337
in ``filename`` (one word per line)."""
338+
if verbose:
339+
print(f"Additional dictionary: {filename}")
340+
338341
with open(filename) as f:
339342
lines = f.read().splitlines()
340343

@@ -349,30 +352,30 @@ def main():
349352

350353
sitk_dict = Dict("en_US")
351354

355+
# Set the amount of debugging messages to print.
356+
output_lvl = 1
357+
if args.brief:
358+
output_lvl = 0
359+
else:
360+
if args.verbose:
361+
output_lvl = 2
362+
if args.miss:
363+
output_lvl = -1
364+
352365
# Load the dictionary files
353366
#
354367
initial_dct = Path(__file__).parent / "additional_dictionary.txt"
355368
if not initial_dct.exists():
356369
initial_dct = None
357370
else:
358-
add_dict(sitk_dict, str(initial_dct))
371+
add_dict(sitk_dict, str(initial_dct), any([args.brief, output_lvl >= 0]))
359372

360373
if args.dict is not None:
361374
for d in args.dict:
362-
add_dict(sitk_dict, d)
375+
add_dict(sitk_dict, d, any([args.brief, output_lvl >= 0]))
363376

364377
spell_checker = SpellChecker(sitk_dict, filters=[EmailFilter, URLFilter])
365378

366-
# Set the amount of debugging messages to print.
367-
output_lvl = 1
368-
if args.brief:
369-
output_lvl = 0
370-
else:
371-
if args.verbose:
372-
output_lvl = 2
373-
if args.miss:
374-
output_lvl = -1
375-
376379
file_list = []
377380
if len(args.filenames):
378381
file_list = args.filenames

0 commit comments

Comments
 (0)