diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2011-08-22 22:52:03 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2011-08-22 22:52:03 -0400 |
commit | 9b1f4aa3fdca6876ec95b7fb74be8f4a02abb300 (patch) | |
tree | d1fba710120dfb06f2fe44c1b52d8b45c796174a /coverage/files.py | |
parent | 103d412fe44d335804b3fa149da6ce7e686943e0 (diff) | |
download | python-coveragepy-git-9b1f4aa3fdca6876ec95b7fb74be8f4a02abb300.tar.gz |
Move a method to be a function.
Diffstat (limited to 'coverage/files.py')
-rw-r--r-- | coverage/files.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/coverage/files.py b/coverage/files.py index 93a5ab2f..5ec3d80c 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -119,6 +119,16 @@ class FnmatchMatcher(object): return False +def sep(s): + """Find the path separator used in this string, or os.sep if none.""" + sep_match = re.search(r"[\\/]", s) + if sep_match: + the_sep = sep_match.group(0) + else: + the_sep = os.sep + return the_sep + + class PathAliases(object): """A collection of aliases for paths. @@ -133,15 +143,6 @@ class PathAliases(object): def __init__(self): self.aliases = [] - def _sep(self, s): - """Find the path separator used in this string, or os.sep if none.""" - sep_match = re.search(r"[\\/]", s) - if sep_match: - sep = sep_match.group(0) - else: - sep = os.sep - return sep - def add(self, pattern, result): """Add the `pattern`/`result` pair to the list of aliases. @@ -159,7 +160,7 @@ class PathAliases(object): pattern = pattern.rstrip(r"\/") if pattern.endswith("*"): raise CoverageException("Pattern must not end with wildcards.") - pattern_sep = self._sep(pattern) + pattern_sep = sep(pattern) pattern += pattern_sep # Make a regex from the pattern. fnmatch always adds a \Z or $ to @@ -170,7 +171,7 @@ class PathAliases(object): regex = re.compile("(?i)" + regex_pat) # Normalize the result: it must end with a path separator. - result_sep = self._sep(result) + result_sep = sep(result) result = result.rstrip(r"\/") + result_sep self.aliases.append((regex, result, pattern_sep, result_sep)) |