summaryrefslogtreecommitdiff
path: root/coverage/control.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-04-10 08:42:31 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-04-10 08:42:31 -0400
commit52e07c90b77b1d07ed95a6195ec5d895f0988224 (patch)
tree325346a20aedac88b3297919f5c1c89f79de7aed /coverage/control.py
parentd4dd809d27ad7f31431a4ef61309b6951ad41d9b (diff)
parent822b7c82f58bbd6f2b38cc98c7881cc405d0c69e (diff)
downloadpython-coveragepy-52e07c90b77b1d07ed95a6195ec5d895f0988224.tar.gz
Merge Brett's __main__.py file for the tree.
Diffstat (limited to 'coverage/control.py')
-rw-r--r--coverage/control.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/coverage/control.py b/coverage/control.py
index 514f23d..dd65661 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -118,8 +118,8 @@ class coverage(object):
else:
self.source_pkgs.append(src)
- self.omit = self._abs_files(self.config.omit)
- self.include = self._abs_files(self.config.include)
+ self.omit = self._prep_patterns(self.config.omit)
+ self.include = self._prep_patterns(self.config.include)
self.collector = Collector(
self._should_trace, timid=self.config.timid,
@@ -226,8 +226,8 @@ class coverage(object):
self._check_for_packages()
# Compiled Python files have two filenames: frame.f_code.co_filename is
- # the filename at the time the .pyc was compiled. The second name
- # is __file__, which is where the .pyc was actually loaded from. Since
+ # the filename at the time the .pyc was compiled. The second name is
+ # __file__, which is where the .pyc was actually loaded from. Since
# .pyc files can be moved after compilation (for example, by being
# installed), we look for __file__ in the frame and prefer it to the
# co_filename value.
@@ -280,10 +280,24 @@ class coverage(object):
self._warnings.append(msg)
sys.stderr.write("Coverage.py warning: %s\n" % msg)
- def _abs_files(self, files):
- """Return a list of absolute file names for the names in `files`."""
- files = files or []
- return [self.file_locator.abs_file(f) for f in files]
+ def _prep_patterns(self, patterns):
+ """Prepare the file patterns for use in a `FnmatchMatcher`.
+
+ If a pattern starts with a wildcard, it is used as a pattern
+ as-is. If it does not start with a wildcard, then it is made
+ absolute with the current directory.
+
+ If `patterns` is None, an empty list is returned.
+
+ """
+ patterns = patterns or []
+ prepped = []
+ for p in patterns or []:
+ if p.startswith("*") or p.startswith("?"):
+ prepped.append(p)
+ else:
+ prepped.append(self.file_locator.abs_file(p))
+ return prepped
def _check_for_packages(self):
"""Update the source_match matcher with latest imported packages."""