From 19109e4a0cedb6c1fd322a9da188bcf0211440cc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 6 Sep 2014 14:24:15 -0400 Subject: Move dispositions closer to useful plugins --- coverage/plugin.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'coverage/plugin.py') 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 -- cgit v1.2.1