diff options
author | Danny Allen <me@dannya.com> | 2014-08-11 16:13:06 +0100 |
---|---|---|
committer | Danny Allen <me@dannya.com> | 2014-08-11 16:13:06 +0100 |
commit | e38016c499921dd7bf5919a699a76305a1936129 (patch) | |
tree | 07a4125732561f2489dfb6b75a339cfef46d80d4 /coverage/parser.py | |
parent | c81183f614ca982cd2ed93ac8e6e76610d162202 (diff) | |
parent | ee5ea987f8978d91c1ef189fe4f334511ddf6215 (diff) | |
download | python-coveragepy-git-e38016c499921dd7bf5919a699a76305a1936129.tar.gz |
Merged ned/coveragepy into default
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index cfaf02fa..c5e95baa 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -14,23 +14,11 @@ 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 + return set(lines) + + def translate_arcs(self, arcs): + return arcs def exit_counts(self): return {} @@ -42,7 +30,7 @@ class CodeParser(object): class PythonParser(CodeParser): """Parse code to find executable lines, excluded lines, etc.""" - def __init__(self, cu, text=None, filename=None, exclude=None): + def __init__(self, text=None, filename=None, exclude=None): """ Source can be provided as `text`, the text itself, or `filename`, from which the text will be read. Excluded lines are those that match @@ -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. |