11 import posixpath |
11 import posixpath |
12 import re |
12 import re |
13 import sys |
13 import sys |
14 |
14 |
15 from coverage import env |
15 from coverage import env |
16 from coverage.exceptions import CoverageException |
16 from coverage.exceptions import ConfigError |
17 from coverage.misc import contract, human_sorted, isolate_module, join_regex |
17 from coverage.misc import contract, human_sorted, isolate_module, join_regex |
18 |
18 |
19 |
19 |
20 os = isolate_module(os) |
20 os = isolate_module(os) |
21 |
21 |
135 actpath = os.path.join(head, tail) |
135 actpath = os.path.join(head, tail) |
136 _ACTUAL_PATH_CACHE[path] = actpath |
136 _ACTUAL_PATH_CACHE[path] = actpath |
137 return actpath |
137 return actpath |
138 |
138 |
139 else: |
139 else: |
140 def actual_path(filename): |
140 def actual_path(path): |
141 """The actual path for non-Windows platforms.""" |
141 """The actual path for non-Windows platforms.""" |
142 return filename |
142 return path |
143 |
143 |
144 |
144 |
145 @contract(returns='unicode') |
145 @contract(returns='unicode') |
146 def abs_file(path): |
146 def abs_file(path): |
147 """Return the absolute normalized form of `path`.""" |
147 """Return the absolute normalized form of `path`.""" |
354 if len(pattern) > 1: |
354 if len(pattern) > 1: |
355 pattern = pattern.rstrip(r"\/") |
355 pattern = pattern.rstrip(r"\/") |
356 |
356 |
357 # The pattern can't end with a wildcard component. |
357 # The pattern can't end with a wildcard component. |
358 if pattern.endswith("*"): |
358 if pattern.endswith("*"): |
359 raise CoverageException("Pattern must not end with wildcards.") |
359 raise ConfigError("Pattern must not end with wildcards.") |
360 |
360 |
361 # The pattern is meant to match a filepath. Let's make it absolute |
361 # The pattern is meant to match a filepath. Let's make it absolute |
362 # unless it already is, or is meant to match any prefix. |
362 # unless it already is, or is meant to match any prefix. |
363 if not pattern.startswith('*') and not isabs_anywhere(pattern + |
363 if not pattern.startswith('*') and not isabs_anywhere(pattern + |
364 pattern_sep): |
364 pattern_sep): |