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
commit0891e02eb490494ee40a7f840e4ab9fd6b3d2d7b (patch)
tree394c5e68d986579d94a153b15dee8ac977c643bd /coverage/plugin.py
parent7862e1fee15b6ef8fcadfd112cf93121ed8f388e (diff)
downloadpython-coveragepy-git-0891e02eb490494ee40a7f840e4ab9fd6b3d2d7b.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 8e26ae6b..84d81a28 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