summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2012-06-13 18:13:06 +0200
committerFlorent Xicluna <florent.xicluna@gmail.com>2012-06-13 18:13:06 +0200
commit845b5196981660b9290b5b249ccead4dbe2782db (patch)
tree462e25a4201399c27262252f6f429690227a8398
parent0811d09b12650e39735d44f56c0387df897a7a5b (diff)
downloadpep8-845b5196981660b9290b5b249ccead4dbe2782db.tar.gz
Reuse the helper filename_match.
-rwxr-xr-xpep8.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/pep8.py b/pep8.py
index 879a4d5..f292a8f 100755
--- a/pep8.py
+++ b/pep8.py
@@ -1196,13 +1196,13 @@ def find_checks(argument_name):
yield name, codes, function, args
-def filename_match(filename, patterns):
+def filename_match(filename, patterns, default=True):
"""
Check if patterns contains a pattern that matches filename.
If patterns is unspecified, this always returns True.
"""
if not patterns:
- return True
+ return default
for pattern in patterns:
if fnmatch(filename, pattern):
return True
@@ -1658,10 +1658,7 @@ class StyleGuide(object):
Check if options.exclude contains a pattern that matches filename.
"""
basename = os.path.basename(filename)
- for pattern in self.options.exclude:
- if fnmatch(basename, pattern):
- # print basename, 'excluded because it matches', pattern
- return True
+ return filename_match(basename, self.options.exclude, default=False)
def ignore_code(self, code):
"""