Index: third_party/coverage-3.7.1/coverage/files.py |
diff --git a/third_party/coverage-3.6/coverage/files.py b/third_party/coverage-3.7.1/coverage/files.py |
similarity index 90% |
rename from third_party/coverage-3.6/coverage/files.py |
rename to third_party/coverage-3.7.1/coverage/files.py |
index 3a3a7732afefed32706046118713357ee8f9ae54..464535a81653ca833ba33b462467941e373c0927 100644 |
--- a/third_party/coverage-3.6/coverage/files.py |
+++ b/third_party/coverage-3.7.1/coverage/files.py |
@@ -3,6 +3,7 @@ |
from coverage.backward import to_string |
from coverage.misc import CoverageException |
import fnmatch, os, os.path, re, sys |
+import ntpath, posixpath |
class FileLocator(object): |
"""Understand how filenames work.""" |
@@ -110,13 +111,20 @@ else: |
"""The actual path for non-Windows platforms.""" |
return filename |
+ |
def abs_file(filename): |
"""Return the absolute normalized form of `filename`.""" |
- path = os.path.abspath(os.path.realpath(filename)) |
+ path = os.path.expandvars(os.path.expanduser(filename)) |
+ path = os.path.abspath(os.path.realpath(path)) |
path = actual_path(path) |
return path |
+def isabs_anywhere(filename): |
+ """Is `filename` an absolute path on any OS?""" |
+ return ntpath.isabs(filename) or posixpath.isabs(filename) |
+ |
+ |
def prep_patterns(patterns): |
"""Prepare the file patterns for use in a `FnmatchMatcher`. |
@@ -127,7 +135,6 @@ def prep_patterns(patterns): |
If `patterns` is None, an empty list is returned. |
""" |
- patterns = patterns or [] |
prepped = [] |
for p in patterns or []: |
if p.startswith("*") or p.startswith("?"): |
@@ -145,6 +152,10 @@ class TreeMatcher(object): |
def __repr__(self): |
return "<TreeMatcher %r>" % self.dirs |
+ def info(self): |
+ """A list of strings for displaying when dumping state.""" |
+ return self.dirs |
+ |
def add(self, directory): |
"""Add another directory to the list we match for.""" |
self.dirs.append(directory) |
@@ -170,6 +181,10 @@ class FnmatchMatcher(object): |
def __repr__(self): |
return "<FnmatchMatcher %r>" % self.pats |
+ def info(self): |
+ """A list of strings for displaying when dumping state.""" |
+ return self.pats |
+ |
def match(self, fpath): |
"""Does `fpath` match one of our filename patterns?""" |
for pat in self.pats: |
@@ -223,6 +238,11 @@ class PathAliases(object): |
if pattern.endswith("*"): |
raise CoverageException("Pattern must not end with wildcards.") |
pattern_sep = sep(pattern) |
+ |
+ # The pattern is meant to match a filepath. Let's make it absolute |
+ # unless it already is, or is meant to match any prefix. |
+ if not pattern.startswith('*') and not isabs_anywhere(pattern): |
+ pattern = abs_file(pattern) |
pattern += pattern_sep |
# Make a regex from the pattern. fnmatch always adds a \Z or $ to |
@@ -230,7 +250,7 @@ class PathAliases(object): |
regex_pat = fnmatch.translate(pattern).replace(r'\Z(', '(') |
if regex_pat.endswith("$"): |
regex_pat = regex_pat[:-1] |
- # We want */a/b.py to match on Windows to, so change slash to match |
+ # We want */a/b.py to match on Windows too, so change slash to match |
# either separator. |
regex_pat = regex_pat.replace(r"\/", r"[\\/]") |
# We want case-insensitive matching, so add that flag. |
@@ -283,7 +303,7 @@ def find_python_files(dirname): |
continue |
for filename in filenames: |
# We're only interested in files that look like reasonable Python |
- # files: Must end with .py, and must not have certain funny |
+ # files: Must end with .py or .pyw, and must not have certain funny |
# characters that probably mean they are editor junk. |
- if re.match(r"^[^.#~!$@%^&*()+=,]+\.py$", filename): |
+ if re.match(r"^[^.#~!$@%^&*()+=,]+\.pyw?$", filename): |
yield os.path.join(dirpath, filename) |