diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index 52f7cf1e987..e48570aafcc 100755 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -875,7 +875,8 @@ def main(*args): if os.path.isdir(filename): for root, dirs, files in os.walk(filename): - if glob_match.match(root): # skip (absolute) directories + rel_root = os.path.relpath(root, filename) + if glob_match.match(rel_root): # skip directory (rel. path) del dirs[:] continue if is_hidden(root, options.check_hidden): # dir itself hidden @@ -884,20 +885,21 @@ def main(*args): # ignore hidden files in directories if is_hidden(file_, options.check_hidden): continue - if glob_match.match(file_): # skip files + if glob_match.match(file_): # skip file (base name) continue - fname = os.path.join(root, file_) - if glob_match.match(fname): # skip paths + rel_path = os.path.join(rel_root, file_) + if glob_match.match(rel_path): # skip file (rel. path) continue + abs_path = os.path.join(root, file_) bad_count += parse_file( - fname, colors, summary, misspellings, exclude_lines, + abs_path, colors, summary, misspellings, exclude_lines, file_opener, word_regex, ignore_word_regex, uri_regex, uri_ignore_words, context, options) - # skip (relative) directories + # skip directory (base name) dirs[:] = [dir_ for dir_ in dirs if not glob_match.match(dir_)] - elif not glob_match.match(filename): # skip files + elif not glob_match.match(filename): # skip file bad_count += parse_file( filename, colors, summary, misspellings, exclude_lines, file_opener, word_regex, ignore_word_regex, uri_regex,