summaryrefslogtreecommitdiff
path: root/coverage
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
commit1ea2b87c872b8ae92f0b89f14c93786fcf1b87e2 (patch)
tree8193f0bfe502adab6b539f59567cd0f9f5ae4b8a /coverage
parent9f69294116672d820d174667f29151a185ab18e1 (diff)
downloadpython-coveragepy-1ea2b87c872b8ae92f0b89f14c93786fcf1b87e2.tar.gz
Some prep work for finding completely uncovered files.
Diffstat (limited to 'coverage')
-rw-r--r--coverage/data.py5
-rw-r--r--coverage/files.py14
2 files changed, 18 insertions, 1 deletions
diff --git a/coverage/data.py b/coverage/data.py
index fe076be..6d49f71 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -52,7 +52,10 @@ class CoverageData(object):
# A map from canonical Python source file name to a dictionary with an
# entry for each pair of line numbers forming an arc:
#
- # { filename: { (l1,l2): None, ... }, ...}
+ # {
+ # 'filename1.py': { (12,14): None, (47,48): None, ... },
+ # ...
+ # }
#
self.arcs = {}
diff --git a/coverage/files.py b/coverage/files.py
index 741b456..9a8ac56 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)