diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-01-24 17:08:03 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-01-24 17:08:03 -0500 |
commit | e3ec6ed046f33edcfa7f0b03d1a22dc607149d4c (patch) | |
tree | a153ec9363cee535130dbdb3c6402781cdc03c49 /coverage/plugin.py | |
parent | 3ae4d48e9bb6cef7e389e5daba8d4ffc4b46102b (diff) | |
download | python-coveragepy-git-e3ec6ed046f33edcfa7f0b03d1a22dc607149d4c.tar.gz |
Move a helper from plugin.py to misc.py
Diffstat (limited to 'coverage/plugin.py')
-rw-r--r-- | coverage/plugin.py | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/coverage/plugin.py b/coverage/plugin.py index 64767e5e..c80a1a24 100644 --- a/coverage/plugin.py +++ b/coverage/plugin.py @@ -1,26 +1,6 @@ -""" -Coverage.py's behavior can be extended by writing plugins. These are Python -classes installed separately, and then configured in your .coveragerc file. - -""" - - -# TODO: abc? -def _needs_to_implement(that, func_name): - """Helper to raise NotImplementedError in interface stubs.""" - if hasattr(that, "plugin_name"): - thing = "Plugin" - name = that.plugin_name - else: - thing = "Class" - klass = that.__class__ - name = "{klass.__module__}.{klass.__name__}".format(klass=klass) - - raise NotImplementedError( - "{thing} {name!r} needs to implement {func_name}()".format( - thing=thing, name=name, func_name=func_name - ) - ) +"""Plugin interfaces for coverage.py""" + +from coverage.misc import _needs_to_implement class CoveragePlugin(object): @@ -117,8 +97,8 @@ class FileTracer(object): Some plugins need to compute the source filename dynamically for each frame. - This function will not be invoked if :meth:`has_dynamic_source_filename` - returns False. + This function will not be invoked if + :meth:`has_dynamic_source_filename` returns False. Returns: The source filename for this frame, or None if this frame shouldn't @@ -227,4 +207,9 @@ class FileReporter(object): def flat_rootname(self): # TODO: a better generic implementation? - return self.filename.replace('\\', '_').replace('/', '_').replace('.', '_') + return ( + self.filename + .replace('\\', '_') + .replace('/', '_') + .replace('.', '_') + ) |