summaryrefslogtreecommitdiff
path: root/coverage/plugin.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2014-09-06 14:24:15 -0400
committerNed Batchelder <ned@nedbatchelder.com>2014-09-06 14:24:15 -0400
commit19109e4a0cedb6c1fd322a9da188bcf0211440cc (patch)
treebab840acd64f5f937eea68c31fd03be47e6aa5e2 /coverage/plugin.py
parent1d3a76ebe7211210731886f237657060474660a0 (diff)
downloadpython-coveragepy-19109e4a0cedb6c1fd322a9da188bcf0211440cc.tar.gz
Move dispositions closer to useful plugins
Diffstat (limited to 'coverage/plugin.py')
-rw-r--r--coverage/plugin.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/coverage/plugin.py b/coverage/plugin.py
index 8e26ae6..84d81a2 100644
--- a/coverage/plugin.py
+++ b/coverage/plugin.py
@@ -8,6 +8,37 @@ class CoveragePlugin(object):
def __init__(self, options):
self.options = options
+ def trace_judge(self):
+ """Return a callable that can decide whether to trace a file or not.
+
+ The callable should take a filename, and return a coverage.TraceDisposition
+ object.
+
+ """
+ return None
+
+ # TODO: why does trace_judge return a callable, but source_file_name is callable?
+ def source_file_name(self, filename):
+ """Return the source name for a given Python filename.
+
+ Can return None if tracing shouldn't continue.
+
+ """
+ return filename
+
+ def dynamic_source_file_name(self):
+ """Returns a callable that can return a source name for a frame.
+
+ The callable should take a filename and a frame, and return either a
+ filename or None:
+
+ def dynamic_source_filename_func(filename, frame)
+
+ Can return None if dynamic filenames aren't needed.
+
+ """
+ return None
+
def load_plugins(modules, config):
"""Load plugins from `modules`.
@@ -25,6 +56,7 @@ def load_plugins(modules, config):
if plugin_class:
options = config.get_plugin_options(module)
plugin = plugin_class(options)
+ plugin.__name__ = module
plugins.append(plugin)
return plugins