diff options
-rw-r--r-- | coverage/control.py | 6 | ||||
-rw-r--r-- | coverage/parser.py (renamed from coverage/analyzer.py) | 28 |
2 files changed, 17 insertions, 17 deletions
diff --git a/coverage/control.py b/coverage/control.py index 5fc08247..240a75f3 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -112,7 +112,7 @@ class coverage: missing from execution, and (5), a readable string of missing lines. """ - from coverage.analyzer import CodeAnalyzer + from coverage.parser import CodeParser filename = code_unit.filename ext = os.path.splitext(filename)[1] @@ -128,8 +128,8 @@ class coverage: "No source for code '%s'." % code_unit.filename ) - analyzer = CodeAnalyzer() - statements, excluded, line_map = analyzer.analyze_source( + parser = CodeParser() + statements, excluded, line_map = parser.parse_source( text=source, filename=filename, exclude=self.exclude_re ) diff --git a/coverage/analyzer.py b/coverage/parser.py index 55dae7f7..b1997b11 100644 --- a/coverage/analyzer.py +++ b/coverage/parser.py @@ -1,4 +1,4 @@ -"""Code analysis for coverage.py""" +"""Code parsing for coverage.py""" import re, token, tokenize, types import cStringIO as StringIO @@ -14,13 +14,13 @@ except NameError: set = sets.Set # pylint: disable-msg=W0622 -class CodeAnalyzer: - """Analyze code to find executable lines, excluded lines, etc.""" +class CodeParser: + """Parse code to find executable lines, excluded lines, etc.""" def __init__(self, show_tokens=False): self.show_tokens = show_tokens - # The text lines of the analyzed code. + # The text lines of the parsed code. self.lines = None # The line numbers of excluded lines of code. @@ -75,8 +75,8 @@ class CodeAnalyzer: # Found another code object, so recurse into it. self.find_statements(c) - def raw_analyze(self, text=None, filename=None, exclude=None): - """Analyze `text` to find the interesting facts about its lines. + def raw_parse(self, text=None, filename=None, exclude=None): + """Parse `text` to find the interesting facts about its lines. A handful of member fields are updated. @@ -190,8 +190,8 @@ class CodeAnalyzer: lines.sort() return lines - def analyze_source(self, text=None, filename=None, exclude=None): - """Analyze source text to find executable lines, excluded lines, etc. + def parse_source(self, text=None, filename=None, exclude=None): + """Parse source text to find executable lines, excluded lines, etc. Source can be provided as `text`, the text itself, or `filename`, from which text will be read. Excluded lines are those that match `exclude`, @@ -202,7 +202,7 @@ class CodeAnalyzer: numbers to pairs (lo,hi) for multi-line statements. """ - self.raw_analyze(text, filename, exclude) + self.raw_parse(text, filename, exclude) excluded_lines = self.map_to_first_line(self.excluded) ignore = excluded_lines + list(self.docstrings) @@ -210,8 +210,8 @@ class CodeAnalyzer: return lines, excluded_lines, self.multiline - def print_analysis(self): - """Print the results of the analysis.""" + def print_parse_results(self): + """Print the results of the parsing.""" for i, ltext in enumerate(self.lines): lineno = i+1 m0 = m1 = m2 = ' ' @@ -227,6 +227,6 @@ class CodeAnalyzer: if __name__ == '__main__': import sys - analyzer = CodeAnalyzer(show_tokens=True) - analyzer.raw_analyze(filename=sys.argv[1], exclude=r"no\s*cover") - analyzer.print_analysis() + parser = CodeParser(show_tokens=True) + parser.raw_parse(filename=sys.argv[1], exclude=r"no\s*cover") + parser.print_parse_results() |