eric6/DebugClients/Python/coverage/plugin_support.py

changeset 7427
362cd1b6f81a
parent 6942
2602857055c5
equal deleted inserted replaced
7426:dc171b1d8261 7427:362cd1b6f81a
1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 1 # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
2 # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt 2 # For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt
3 3
4 """Support for plugins.""" 4 """Support for plugins."""
5 5
6 import os 6 import os
7 import os.path 7 import os.path
19 def __init__(self): 19 def __init__(self):
20 self.order = [] 20 self.order = []
21 self.names = {} 21 self.names = {}
22 self.file_tracers = [] 22 self.file_tracers = []
23 self.configurers = [] 23 self.configurers = []
24 self.context_switchers = []
24 25
25 self.current_module = None 26 self.current_module = None
26 self.debug = None 27 self.debug = None
27 28
28 @classmethod 29 @classmethod
67 `plugin` is an instance of a third-party plugin class. It must 68 `plugin` is an instance of a third-party plugin class. It must
68 implement the :meth:`CoveragePlugin.configure` method. 69 implement the :meth:`CoveragePlugin.configure` method.
69 70
70 """ 71 """
71 self._add_plugin(plugin, self.configurers) 72 self._add_plugin(plugin, self.configurers)
73
74 def add_dynamic_context(self, plugin):
75 """Add a dynamic context plugin.
76
77 `plugin` is an instance of a third-party plugin class. It must
78 implement the :meth:`CoveragePlugin.dynamic_context` method.
79
80 """
81 self._add_plugin(plugin, self.context_switchers)
72 82
73 def add_noop(self, plugin): 83 def add_noop(self, plugin):
74 """Add a plugin that does nothing. 84 """Add a plugin that does nothing.
75 85
76 This is only useful for testing the plugin support. 86 This is only useful for testing the plugin support.
155 if reporter: 165 if reporter:
156 debug = self.debug.add_label("file %r" % (filename,)) 166 debug = self.debug.add_label("file %r" % (filename,))
157 reporter = DebugFileReporterWrapper(filename, reporter, debug) 167 reporter = DebugFileReporterWrapper(filename, reporter, debug)
158 return reporter 168 return reporter
159 169
170 def dynamic_context(self, frame):
171 context = self.plugin.dynamic_context(frame)
172 self.debug.write("dynamic_context(%r) --> %r" % (frame, context))
173 return context
174
175 def find_executable_files(self, src_dir):
176 executable_files = self.plugin.find_executable_files(src_dir)
177 self.debug.write("find_executable_files(%r) --> %r" % (src_dir, executable_files))
178 return executable_files
179
180 def configure(self, config):
181 self.debug.write("configure(%r)" % (config,))
182 self.plugin.configure(config)
183
160 def sys_info(self): 184 def sys_info(self):
161 return self.plugin.sys_info() 185 return self.plugin.sys_info()
162 186
163 187
164 class DebugFileTracerWrapper(FileTracer): 188 class DebugFileTracerWrapper(FileTracer):

eric ide

mercurial