diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-05-18 14:12:09 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-05-18 14:12:09 -0400 |
commit | 0e9645871302491b6329f0c57d3d9fdeba967e74 (patch) | |
tree | 36a31a48f3987e5a891589a483ff1bcd43c40822 /coverage/parser.py | |
parent | a2a2f5088c9e53540df81349980d1733727976f5 (diff) | |
download | python-coveragepy-0e9645871302491b6329f0c57d3d9fdeba967e74.tar.gz |
A bit of refactoring, inching slowly toward nicer CodeUnits
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index cfaf02f..88aad65 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -14,24 +14,12 @@ class CodeParser(object): """ Base class for any code parser. """ - def _adjust_filename(self, fname): - return fname - - def first_lines(self, lines): - """Map the line numbers in `lines` to the correct first line of the - statement. - - Returns a set of the first lines. - - """ - return set(self.first_line(l) for l in lines) - - def first_line(self, line): - return line - def translate_lines(self, lines): return lines + def translate_arcs(self, arcs): + return arcs + def exit_counts(self): return {} @@ -197,6 +185,24 @@ class PythonParser(CodeParser): else: return line + def first_lines(self, lines): + """Map the line numbers in `lines` to the correct first line of the + statement. + + Returns a set of the first lines. + + """ + return set(self.first_line(l) for l in lines) + + def translate_lines(self, lines): + return self.first_lines(lines) + + def translate_arcs(self, arcs): + return [ + (self.first_line(a), self.first_line(b)) + for (a, b) in arcs + ] + def parse_source(self): """Parse source text to find executable lines, excluded lines, etc. |