diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-01-09 21:03:09 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-01-09 21:03:09 -0500 |
commit | e738d389177b80f6b93e9eacb1828294419c7ef4 (patch) | |
tree | 2c498841df4da0a33c9e4d4f971bdfd12dedac39 /coverage/codeunit.py | |
parent | 0d1bc9fa8a3723c1929138f3b6feb1cfdb478e07 (diff) | |
download | python-coveragepy-git-e738d389177b80f6b93e9eacb1828294419c7ef4.tar.gz |
Move base-class logic from CodeUnit to FileReporter
Diffstat (limited to 'coverage/codeunit.py')
-rw-r--r-- | coverage/codeunit.py | 50 |
1 files changed, 2 insertions, 48 deletions
diff --git a/coverage/codeunit.py b/coverage/codeunit.py index b2c9a71e..4e64bb0d 100644 --- a/coverage/codeunit.py +++ b/coverage/codeunit.py @@ -4,9 +4,10 @@ import os from coverage.backward import unicode_class from coverage.files import FileLocator +from coverage.plugin import FileReporter -class CodeUnit(object): +class CodeUnit(FileReporter): """Code unit: a filename or module. Instance attributes: @@ -42,38 +43,10 @@ class CodeUnit(object): self.name = n self.modname = modname - def __repr__(self): - return ( - "<{self.__class__.__name__}" - " name={self.name!r}" - " filename={self.filename!r}>".format(self=self) - ) - def _adjust_filename(self, f): # TODO: This shouldn't be in the base class, right? return f - # Annoying comparison operators. Py3k wants __lt__ etc, and Py2k needs all - # of them defined. - - def __lt__(self, other): - return self.name < other.name - - def __le__(self, other): - return self.name <= other.name - - def __eq__(self, other): - return self.name == other.name - - def __ne__(self, other): - return self.name != other.name - - def __gt__(self, other): - return self.name > other.name - - def __ge__(self, other): - return self.name >= other.name - def flat_rootname(self): """A base for a flat filename to correspond to this code unit. @@ -89,22 +62,3 @@ class CodeUnit(object): else: root = os.path.splitdrive(self.name)[1] return root.replace('\\', '_').replace('/', '_').replace('.', '_') - - def source(self): - """Return the source for the code, a Unicode string.""" - return unicode_class("???") - - def source_token_lines(self): - """Return the 'tokenized' text for the code.""" - # A generic implementation, each line is one "txt" token. - for line in self.source().splitlines(): - yield [('txt', line)] - - def should_be_python(self): - """Does it seem like this file should contain Python? - - This is used to decide if a file reported as part of the execution of - a program was really likely to have contained Python in the first - place. - """ - return False |