summaryrefslogtreecommitdiff
path: root/coverage/files.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2010-08-30 23:08:39 -0400
committerNed Batchelder <ned@nedbatchelder.com>2010-08-30 23:08:39 -0400
commitb8a9e1e21d728e4dd783a4aaecba81dc4f0b11f3 (patch)
treeced71b31e8b9d3fc238ef0fd9e76fdcefd21d664 /coverage/files.py
parent95b6988b7728fca012cc1469587f7316c80b4d78 (diff)
downloadpython-coveragepy-git-b8a9e1e21d728e4dd783a4aaecba81dc4f0b11f3.tar.gz
Some prep work for finding completely uncovered files.
Diffstat (limited to 'coverage/files.py')
-rw-r--r--coverage/files.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/coverage/files.py b/coverage/files.py
index 741b456f..9a8ac564 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -102,6 +102,7 @@ class TreeMatcher(object):
return True
return False
+
class FnmatchMatcher(object):
"""A matcher for files by filename pattern."""
def __init__(self, pats):
@@ -116,3 +117,16 @@ class FnmatchMatcher(object):
if fnmatch.fnmatch(fpath, pat):
return True
return False
+
+
+def find_python_files(dirname):
+ """Yield all of the importable Python files in `dirname`, recursively."""
+ for dirpath, dirnames, filenames in os.walk(dirname, topdown=True):
+ if '__init__.py' not in filenames:
+ # If a directory doesn't have __init__.py, then it isn't
+ # importable and neither are its files
+ del dirnames[:]
+ continue
+ for filename in filenames:
+ if fnmatch.fnmatch(filename, "*.py"):
+ yield os.path.join(dirpath, filename)