summaryrefslogtreecommitdiff
path: root/coverage/plugin.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-08-09 12:20:02 -0400
committerNed Batchelder <ned@nedbatchelder.com>2015-08-09 12:20:02 -0400
commitf5340981f611c102bac62c724543e7ff7ff6cb8a (patch)
tree4c5d3b5efc805d909f20cfbf0928b1ecd88c22d3 /coverage/plugin.py
parentf703ae86ce82834205e791d0c138f901494ddad0 (diff)
downloadpython-coveragepy-f5340981f611c102bac62c724543e7ff7ff6cb8a.tar.gz
Rename .statements and .excluded_statements to .lines and .excluded_lines
Diffstat (limited to 'coverage/plugin.py')
-rw-r--r--coverage/plugin.py66
1 files changed, 42 insertions, 24 deletions
diff --git a/coverage/plugin.py b/coverage/plugin.py
index c569d26..4839529 100644
--- a/coverage/plugin.py
+++ b/coverage/plugin.py
@@ -151,41 +151,35 @@ class FileTracer(object):
class FileReporter(object):
"""Support needed for files during the reporting phase."""
+
def __init__(self, filename):
- # TODO: document that this init happens.
+ """Simple initialization of a `FileReporter`.
+
+ The `filename` argument is the path to the file being reported. This
+ will be available as the `.filename` attribute on the object. Other
+ method implementations on this base class rely on this attribute.
+
+ """
self.filename = filename
def __repr__(self):
return "<{0.__class__.__name__} filename={0.filename!r}>".format(self)
def relative_filename(self):
- return files.relative_filename(self.filename)
+ """Return the relative filename for this file.
- # Annoying comparison operators. Py3k wants __lt__ etc, and Py2k needs all
- # of them defined.
-
- def __eq__(self, other):
- return isinstance(other, FileReporter) and self.filename == other.filename
-
- def __ne__(self, other):
- return not (self == other)
+ This file path will be displayed in reports. You only need to supply
+ this method if you have an unusual syntax for file paths. The default
+ implementation will supply the actual project-relative file path.
- def __lt__(self, other):
- return self.filename < other.filename
-
- def __le__(self, other):
- return self.filename <= other.filename
-
- def __gt__(self, other):
- return self.filename > other.filename
-
- def __ge__(self, other):
- return self.filename >= other.filename
+ """
+ return files.relative_filename(self.filename)
- def statements(self):
+ def lines(self):
+ """Return a set of executable lines"""
_needs_to_implement(self, "statements")
- def excluded_statements(self):
+ def excluded_lines(self):
return set([])
def translate_lines(self, lines):
@@ -210,7 +204,31 @@ class FileReporter(object):
return f.read()
def source_token_lines(self):
- """Return the 'tokenized' text for the code."""
+ """Return the 'tokenized' text for the code.
+
+ 'str', 'nam', 'num', 'key', 'com', 'op'
+ """
# A generic implementation, each line is one "txt" token.
for line in self.source().splitlines():
yield [('txt', line)]
+
+ # Annoying comparison operators. Py3k wants __lt__ etc, and Py2k needs all
+ # of them defined.
+
+ def __eq__(self, other):
+ return isinstance(other, FileReporter) and self.filename == other.filename
+
+ def __ne__(self, other):
+ return not (self == other)
+
+ def __lt__(self, other):
+ return self.filename < other.filename
+
+ def __le__(self, other):
+ return self.filename <= other.filename
+
+ def __gt__(self, other):
+ return self.filename > other.filename
+
+ def __ge__(self, other):
+ return self.filename >= other.filename