-
Notifications
You must be signed in to change notification settings - Fork 459
adding directory_filter arg to customized ignored dirs #447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,8 @@ def _strip(line): | |
|
||
def extract_from_dir(dirname=None, method_map=DEFAULT_MAPPING, | ||
options_map=None, keywords=DEFAULT_KEYWORDS, | ||
comment_tags=(), callback=None, strip_comment_tags=False): | ||
comment_tags=(), callback=None, strip_comment_tags=False, | ||
directory_filter=('.','_')): | ||
"""Extract messages from any source files found in the given directory. | ||
|
||
This function generates tuples of the form ``(filename, lineno, message, | ||
|
@@ -128,6 +129,9 @@ def extract_from_dir(dirname=None, method_map=DEFAULT_MAPPING, | |
positional arguments, in that order | ||
:param strip_comment_tags: a flag that if set to `True` causes all comment | ||
tags to be removed from the collected comments. | ||
:param directory_filter: a list of strings that identify the starting | ||
characters of directories to ignore. (optional) | ||
(defaults to ('.', '_')) | ||
:see: `pathmatch` | ||
""" | ||
if dirname is None: | ||
|
@@ -138,7 +142,7 @@ def extract_from_dir(dirname=None, method_map=DEFAULT_MAPPING, | |
absname = os.path.abspath(dirname) | ||
for root, dirnames, filenames in os.walk(absname): | ||
for subdir in dirnames: | ||
if subdir.startswith('.') or subdir.startswith('_'): | ||
if any(subdir.startswith(chars) for chars in directory_filter): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. starstwith can also accept a tuple of strings to try .. so Also while at it, |
||
dirnames.remove(subdir) | ||
dirnames.sort() | ||
filenames.sort() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, this might be more useful if it declared a list of
fnmatch
compatible patterns.Also, now that I think of it, it could maybe just accept a callable? After all there's no command-line support for this argument yet, so it needn't be a "command line compatible". The default could be
default_directory_filter
, defined asand the implementation in the walk loop simply