Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions scspell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ def find_dict_file(override_dictionary):
def spell_check(source_filenames, override_dictionary=None,
base_dicts=[],
relative_to=None, report_only=False, c_escapes=True,
test_input=False):
test_input=False, ext=['']):
"""Run the interactive spell checker on the set of source_filenames.

If override_dictionary is provided, it shall be used as a dictionary
Expand All @@ -691,8 +691,17 @@ def spell_check(source_filenames, override_dictionary=None,
with CorporaFile(dict_file, base_dicts, relative_to) as dicts:
ignores = set()
for f in source_filenames:
if not spell_check_file(f, dicts, ignores, report_only, c_escapes):
okay = False
if not os.path.isdir(f):
if not spell_check_file(f, dicts, ignores, report_only, c_escapes):
okay = False
else:
for dir, subdir, files in os.walk(f):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as @jayvdb about dir being reserved. I see that the code changed, but the name collision is still there.

for fil in files:
for extn in ext:
if fil.endswith(extn):
if not spell_check_file(os.path.join(dir, fil), dicts, ignores, report_only, c_escapes):
okay = False
break
return okay


Expand Down Expand Up @@ -804,6 +813,10 @@ def main():
'--no-c-escapes', dest='c_escapes',
action='store_false', default=True,
help='treat \\label as label, for e.g. LaTeX')
spell_group.add_argument(
'--extensions', '-e', dest='ext',
action='append', default=[],
help='list of extensions to check, in case of directories')

dict_group.add_argument(
'--override-dictionary', dest='override_filename',
Expand Down Expand Up @@ -893,6 +906,9 @@ def main():
if args.debug:
set_verbosity(VERBOSITY_MAX)

if not args.ext:
args.ext.append('')

if args.gen_id:
print('scspell-id: %s' % get_new_file_id())
elif args.dictionary is not None:
Expand Down Expand Up @@ -949,5 +965,6 @@ def main():
args.relative_to,
args.report,
args.c_escapes,
args.test_input)
args.test_input,
args.ext)
return 0 if okay else 1