diff options
-rw-r--r-- | coverage/collector.py | 32 | ||||
-rw-r--r-- | coverage/config.py | 6 | ||||
-rw-r--r-- | coverage/control.py | 26 | ||||
-rw-r--r-- | coverage/data.py | 16 | ||||
-rw-r--r-- | coverage/plugin.py (renamed from coverage/extension.py) | 8 | ||||
-rw-r--r-- | coverage/report.py | 2 |
6 files changed, 46 insertions, 44 deletions
diff --git a/coverage/collector.py b/coverage/collector.py index 546525d2..675758d0 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -47,9 +47,9 @@ class PyTracer(object): self.should_trace = None self.should_trace_cache = None self.warn = None - self.extensions = None + self.plugins = None - self.extension = None + self.plugin = None self.cur_tracename = None # TODO: This is only maintained for the if0 debugging output. Get rid of it eventually. self.cur_file_data = None self.last_line = 0 @@ -112,7 +112,7 @@ class PyTracer(object): if self.coroutine_id_func: self.data_stack = self.data_stacks[self.coroutine_id_func()] self.last_coroutine = self.coroutine_id_func() - self.data_stack.append((self.extension, self.cur_tracename, self.cur_file_data, self.last_line)) + self.data_stack.append((self.plugin, self.cur_tracename, self.cur_file_data, self.last_line)) filename = frame.f_code.co_filename disp = self.should_trace_cache.get(filename) if disp is None: @@ -121,16 +121,16 @@ class PyTracer(object): #print("called, stack is %d deep, tracename is %r" % ( # len(self.data_stack), tracename)) tracename = disp.filename - if tracename and disp.extension: - tracename = disp.extension.file_name(frame) + if tracename and disp.plugin: + tracename = disp.plugin.file_name(frame) if tracename: if tracename not in self.data: self.data[tracename] = {} - if disp.extension: - self.extensions[tracename] = disp.extension.__name__ + if disp.plugin: + self.plugins[tracename] = disp.plugin.__name__ self.cur_tracename = tracename self.cur_file_data = self.data[tracename] - self.extension = disp.extension + self.plugin = disp.plugin else: self.cur_file_data = None # Set the last_line to -1 because the next arc will be entering a @@ -142,8 +142,8 @@ class PyTracer(object): this_coroutine = self.coroutine_id_func() if self.last_coroutine != this_coroutine: print("mismatch: {0} != {1}".format(self.last_coroutine, this_coroutine)) - if self.extension: - lineno_from, lineno_to = self.extension.line_number_range(frame) + if self.plugin: + lineno_from, lineno_to = self.plugin.line_number_range(frame) else: lineno_from, lineno_to = frame.f_lineno, frame.f_lineno if lineno_from != -1: @@ -164,7 +164,7 @@ class PyTracer(object): if self.coroutine_id_func: self.data_stack = self.data_stacks[self.coroutine_id_func()] self.last_coroutine = self.coroutine_id_func() - self.extension, _, self.cur_file_data, self.last_line = self.data_stack.pop() + self.plugin, _, self.cur_file_data, self.last_line = self.data_stack.pop() #print("returned, stack is %d deep" % (len(self.data_stack))) elif event == 'exception': #print("exc", self.last_line, frame.f_lineno) @@ -281,7 +281,7 @@ class Collector(object): # or mapping filenames to dicts with linenumber pairs as keys. self.data = {} - self.extensions = {} + self.plugins = {} # A cache of the results from should_trace, the decision about whether # to trace execution in a file. A dict of filename to (filename or @@ -301,8 +301,8 @@ class Collector(object): tracer.warn = self.warn if hasattr(tracer, 'coroutine_id_func'): tracer.coroutine_id_func = self.coroutine_id_func - if hasattr(tracer, 'extensions'): - tracer.extensions = self.extensions + if hasattr(tracer, 'plugins'): + tracer.plugins = self.plugins fn = tracer.start() self.tracers.append(tracer) return fn @@ -420,5 +420,5 @@ class Collector(object): else: return {} - def get_extension_data(self): - return self.extensions + def get_plugin_data(self): + return self.plugins diff --git a/coverage/config.py b/coverage/config.py index 064bc1ca..1826e5c2 100644 --- a/coverage/config.py +++ b/coverage/config.py @@ -140,7 +140,7 @@ class CoverageConfig(object): self.timid = False self.source = None self.debug = [] - self.extensions = [] + self.plugins = [] # Defaults for [report] self.exclude_list = DEFAULT_EXCLUDE[:] @@ -172,7 +172,7 @@ class CoverageConfig(object): if env: self.timid = ('--timid' in env) - MUST_BE_LIST = ["omit", "include", "debug", "extensions"] + MUST_BE_LIST = ["omit", "include", "debug", "plugins"] def from_args(self, **kwargs): """Read config values from `kwargs`.""" @@ -224,7 +224,7 @@ class CoverageConfig(object): ('cover_pylib', 'run:cover_pylib', 'boolean'), ('data_file', 'run:data_file'), ('debug', 'run:debug', 'list'), - ('extensions', 'run:extensions', 'list'), + ('plugins', 'run:plugins', 'list'), ('include', 'run:include', 'list'), ('omit', 'run:omit', 'list'), ('parallel', 'run:parallel', 'boolean'), diff --git a/coverage/control.py b/coverage/control.py index 1bfd081d..deb4e00f 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -9,7 +9,7 @@ from coverage.collector import Collector from coverage.config import CoverageConfig from coverage.data import CoverageData from coverage.debug import DebugControl -from coverage.extension import load_extensions +from coverage.plugin import load_plugins from coverage.files import FileLocator, TreeMatcher, FnmatchMatcher from coverage.files import PathAliases, find_python_files, prep_patterns from coverage.html import HtmlReporter @@ -45,7 +45,7 @@ class Coverage(object): def __init__(self, data_file=None, data_suffix=None, cover_pylib=None, auto_data=False, timid=None, branch=None, config_file=True, source=None, omit=None, include=None, debug=None, - debug_file=None, coroutine=None): + debug_file=None, coroutine=None, plugins=None): """ `data_file` is the base name of the data file to use, defaulting to ".coverage". `data_suffix` is appended (with a dot) to `data_file` to @@ -87,7 +87,9 @@ class Coverage(object): `coroutine` is a string indicating the coroutining library being used in the measured code. Without this, coverage.py will get incorrect results. Valid strings are "greenlet", "eventlet", or "gevent", which - are all equivalent. + are all equivalent. TODO: really? + + `plugins` TODO. """ from coverage import __version__ @@ -126,15 +128,15 @@ class Coverage(object): data_file=data_file, cover_pylib=cover_pylib, timid=timid, branch=branch, parallel=bool_or_none(data_suffix), source=source, omit=omit, include=include, debug=debug, - coroutine=coroutine, + coroutine=coroutine, plugins=plugins, ) # Create and configure the debugging controller. self.debug = DebugControl(self.config.debug, debug_file or sys.stderr) - # Load extensions - tracer_classes = load_extensions(self.config.extensions, "tracer") - self.tracer_extensions = [cls() for cls in tracer_classes] + # Load plugins + tracer_classes = load_plugins(self.config.plugins, "tracer") + self.tracer_plugins = [cls() for cls in tracer_classes] self.auto_data = auto_data @@ -278,8 +280,8 @@ class Coverage(object): canonical = self.file_locator.canonical_filename(filename) - # Try the extensions, see if they have an opinion about the file. - for tracer in self.tracer_extensions: + # Try the plugins, see if they have an opinion about the file. + for tracer in self.tracer_plugins: ext_disp = tracer.should_trace(canonical) if ext_disp: ext_disp.extension = tracer @@ -543,7 +545,7 @@ class Coverage(object): # TODO: seems like this parallel structure is getting kinda old... self.data.add_line_data(self.collector.get_line_data()) self.data.add_arc_data(self.collector.get_arc_data()) - self.data.add_extension_data(self.collector.get_extension_data()) + self.data.add_plugin_data(self.collector.get_plugin_data()) self.collector.reset() # If there are still entries in the source_pkgs list, then we never @@ -611,7 +613,7 @@ class Coverage(object): """ self._harvest_data() if not isinstance(it, CodeUnit): - get_ext = self.data.extension_data().get + get_ext = self.data.plugin_data().get it = code_unit_factory(it, self.file_locator, get_ext)[0] return Analysis(self, it) @@ -784,7 +786,7 @@ class FileDisposition(object): self.original_filename = original_filename self.filename = None self.reason = "" - self.extension = None + self.plugin = None def nope(self, reason): """A helper for returning a NO answer from should_trace.""" diff --git a/coverage/data.py b/coverage/data.py index b78c931d..e220a364 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -21,9 +21,9 @@ class CoverageData(object): * arcs: a dict mapping filenames to sorted lists of line number pairs: { 'file1': [(17,23), (17,25), (25,26)], ... } - * extensions: a dict mapping filenames to extension names: + * plugins: a dict mapping filenames to plugin names: { 'file1': "django.coverage", ... } - # TODO: how to handle the difference between a extension module + # TODO: how to handle the difference between a plugin module # name, and the class in the module? """ @@ -69,13 +69,13 @@ class CoverageData(object): # self.arcs = {} - # A map from canonical source file name to an extension module name: + # A map from canonical source file name to an plugin module name: # # { # 'filename1.py': 'django.coverage', # ... # } - self.extensions = {} + self.plugins = {} def usefile(self, use_file=True): """Set whether or not to use a disk file for data.""" @@ -123,8 +123,8 @@ class CoverageData(object): (f, sorted(amap.keys())) for f, amap in iitems(self.arcs) ) - def extension_data(self): - return self.extensions + def plugin_data(self): + return self.plugins def write_file(self, filename): """Write the coverage data to `filename`.""" @@ -229,8 +229,8 @@ class CoverageData(object): for filename, arcs in iitems(arc_data): self.arcs.setdefault(filename, {}).update(arcs) - def add_extension_data(self, extension_data): - self.extensions.update(extension_data) + def add_plugin_data(self, plugin_data): + self.plugins.update(plugin_data) def touch_file(self, filename): """Ensure that `filename` appears in the data, empty if needed.""" diff --git a/coverage/extension.py b/coverage/plugin.py index 8c89b88e..0b557106 100644 --- a/coverage/extension.py +++ b/coverage/plugin.py @@ -1,9 +1,9 @@ -"""Extension management for coverage.py""" +"""Plugin management for coverage.py""" -def load_extensions(modules, name): - """Load extensions from `modules`, finding them by `name`. +def load_plugins(modules, name): + """Load plugins from `modules`, finding them by `name`. - Yields the loaded extensions. + Yields the loaded plugins. """ diff --git a/coverage/report.py b/coverage/report.py index 7627d1aa..c91c6e6d 100644 --- a/coverage/report.py +++ b/coverage/report.py @@ -33,7 +33,7 @@ class Reporter(object): """ morfs = morfs or self.coverage.data.measured_files() file_locator = self.coverage.file_locator - get_ext = self.coverage.data.extension_data().get + get_ext = self.coverage.data.plugin_data().get self.code_units = code_unit_factory(morfs, file_locator, get_ext) if self.config.include: |