summaryrefslogtreecommitdiff
path: root/coverage/results.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2014-04-18 21:13:06 -0400
committerNed Batchelder <ned@nedbatchelder.com>2014-04-18 21:13:06 -0400
commite832d01fa66613e8037197861bcd2dd8b3cd9bfe (patch)
tree0b2cc9b31d3b6e0dfa9c2383d9505d3b94aface4 /coverage/results.py
parent929091b59a0bf42864675df5a89e8a52620de9f6 (diff)
downloadpython-coveragepy-git-e832d01fa66613e8037197861bcd2dd8b3cd9bfe.tar.gz
More refactoring of hacked Mako support
Diffstat (limited to 'coverage/results.py')
-rw-r--r--coverage/results.py42
1 files changed, 2 insertions, 40 deletions
diff --git a/coverage/results.py b/coverage/results.py
index 8cac1476..79615c77 100644
--- a/coverage/results.py
+++ b/coverage/results.py
@@ -4,7 +4,7 @@ import collections
import os
from coverage.backward import iitems
-from coverage.misc import format_lines, join_regex, NoSource
+from coverage.misc import format_lines, join_regex
class Analysis(object):
@@ -15,7 +15,7 @@ class Analysis(object):
self.code_unit = code_unit
self.filename = self.code_unit.filename
- actual_filename, source = self.find_source(self.filename)
+ actual_filename, source = self.code_unit.find_source(self.filename)
self.parser = code_unit.parser_class(
code_unit,
@@ -54,44 +54,6 @@ class Analysis(object):
n_missing_branches=n_missing_branches,
)
- def find_source(self, filename):
- """Find the source for `filename`.
-
- Returns two values: the actual filename, and the source.
-
- The source returned depends on which of these cases holds:
-
- * The filename seems to be a non-source file: returns None
-
- * The filename is a source file, and actually exists: returns None.
-
- * The filename is a source file, and is in a zip file or egg:
- returns the source.
-
- * The filename is a source file, but couldn't be found: raises
- `NoSource`.
-
- """
- source = None
-
- base, ext = os.path.splitext(filename)
- TRY_EXTS = {
- '.py': ['.py', '.pyw'],
- '.pyw': ['.pyw'],
- }
- try_exts = TRY_EXTS.get(ext)
- if not try_exts:
- return filename, None
-
- for try_ext in try_exts:
- try_filename = base + try_ext
- if os.path.exists(try_filename):
- return try_filename, None
- source = self.coverage.file_locator.get_zip_data(try_filename)
- if source:
- return try_filename, source
- raise NoSource("No source for code: '%s'" % filename)
-
def missing_formatted(self):
"""The missing line numbers, formatted nicely.