diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-24 12:21:15 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-07-24 12:21:15 -0400 |
commit | 0eb73a211c01852cd3aa9be1c8cc5f9abdb5af32 (patch) | |
tree | 81b51481690baad7e5ccbf866b83f0b5fc11a742 /coverage | |
parent | b99fbf1ff6a06309ecf6cce8d6ae97dee5626784 (diff) | |
download | python-coveragepy-git-0eb73a211c01852cd3aa9be1c8cc5f9abdb5af32.tar.gz |
Use more specific names than 'plugins', since there will be more of them in the future.
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/cmdline.py | 2 | ||||
-rw-r--r-- | coverage/collector.py | 11 | ||||
-rw-r--r-- | coverage/control.py | 2 | ||||
-rw-r--r-- | coverage/data.py | 58 | ||||
-rw-r--r-- | coverage/tracer.c | 8 |
5 files changed, 42 insertions, 39 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index af5ff0c5..10d0f611 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -599,7 +599,7 @@ class CoverageScript(object): print("\n%d files:" % len(filenames)) for f in filenames: line = "%s: %d lines" % (f, summary[f]) - plugin = data.plugin_name(f) + plugin = data.file_tracer(f) if plugin: line += " [%s]" % plugin print(line) diff --git a/coverage/collector.py b/coverage/collector.py index 52a80f60..b8e08414 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -140,8 +140,9 @@ class Collector(object): # pairs as keys (if branch coverage). self.data = {} - # A dictionary mapping filenames to plugin names that will handle them. - self.plugin_data = {} + # A dictionary mapping filenames to file tracer plugin names that will + # handle them. + self.file_tracers = {} # The .should_trace_cache attribute is a cache from filenames to # coverage.FileDisposition objects, or None. When a file is first @@ -193,8 +194,8 @@ class Collector(object): ) ) - if hasattr(tracer, 'plugin_data'): - tracer.plugin_data = self.plugin_data + if hasattr(tracer, 'file_tracers'): + tracer.file_tracers = self.file_tracers if hasattr(tracer, 'threading'): tracer.threading = self.threading if hasattr(tracer, 'check_include'): @@ -309,6 +310,6 @@ class Collector(object): covdata.set_arcs(abs_file_dict(self.data)) else: covdata.set_lines(abs_file_dict(self.data)) - covdata.set_plugins(abs_file_dict(self.plugin_data)) + covdata.set_file_tracers(abs_file_dict(self.file_tracers)) self.reset() diff --git a/coverage/control.py b/coverage/control.py index d5650131..48ee47be 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -834,7 +834,7 @@ class Coverage(object): if isinstance(morf, string_class): abs_morf = abs_file(morf) - plugin_name = self.data.plugin_name(abs_morf) + plugin_name = self.data.file_tracer(abs_morf) if plugin_name: plugin = self.plugins.get(plugin_name) diff --git a/coverage/data.py b/coverage/data.py index 930e04ae..929c521a 100644 --- a/coverage/data.py +++ b/coverage/data.py @@ -42,7 +42,7 @@ class CoverageData(object): To read a coverage.py data file, use :meth:`read_file`, or :meth:`read` if you have an already-opened file. You can then access the line, arc, or - plugin data with :meth:`lines`, :meth:`arcs`, or :meth:`plugin_name`. + plugin data with :meth:`lines`, :meth:`arcs`, or :meth:`file_tracer`. The :meth:`has_arcs` method indicates whether arc data is available. You can get a list of the files in the data with :meth:`measured_files`. @@ -53,9 +53,9 @@ class CoverageData(object): Most data files will be created by coverage.py itself, but you can use methods here to create data files if you like. The :meth:`set_lines`, - :meth:`set_arcs`, and :meth:`set_plugins` methods add data, in ways that - are convenient for coverage.py. To add a file without any measured data, - use :meth:`touch_file`. + :meth:`set_arcs`, and :meth:`set_file_tracers` methods add data, in ways + that are convenient for coverage.py. To add a file without any measured + data, use :meth:`touch_file`. You write to a named file with :meth:`write_file`, or to an already opened file with :meth:`write`. @@ -77,7 +77,7 @@ class CoverageData(object): # # { 'file1': [[17,23], [17,25], [25,26]], ... } # - # * plugins: a dict mapping filenames to plugin names:: + # * file_tracers: a dict mapping filenames to plugin names:: # # { 'file1': "django.coverage", ... } # @@ -113,7 +113,7 @@ class CoverageData(object): # # { 'filename1.py': 'django.coverage', ... } # - self._plugins = {} + self._file_tracers = {} ## ## Reading data @@ -156,8 +156,8 @@ class CoverageData(object): return self._arcs[filename] return None - def plugin_name(self, filename): - """Get the plugin name for a file. + def file_tracer(self, filename): + """Get the plugin name of the file tracer for a file. Arguments: filename: the name of the file you're interested in. @@ -169,10 +169,10 @@ class CoverageData(object): """ # Because the vast majority of files involve no plugin, we don't store - # them explicitly in self._plugins. Check the measured data instead + # them explicitly in self._file_tracers. Check the measured data instead # to see if it was a known file with no plugin. if filename in (self._arcs or self._lines): - return self._plugins.get(filename, "") + return self._file_tracers.get(filename, "") return None def measured_files(self): @@ -217,7 +217,7 @@ class CoverageData(object): (fname, [tuple(pair) for pair in arcs]) for fname, arcs in iitems(data.get('arcs', {})) ) - self._plugins = data.get('plugins', {}) + self._file_tracers = data.get('file_tracers', {}) self._validate() @@ -301,26 +301,26 @@ class CoverageData(object): self._validate() - def set_plugins(self, plugin_data): + def set_file_tracers(self, file_tracers): """Add per-file plugin information. - `plugin_data` is { filename: plugin_name, ... } + `file_tracers` is { filename: plugin_name, ... } """ existing_files = self._arcs or self._lines - for filename, plugin_name in iitems(plugin_data): + for filename, plugin_name in iitems(file_tracers): if filename not in existing_files: raise CoverageException( "Can't add plugin data for unmeasured file '%s'" % (filename,) ) - existing_plugin = self._plugins.get(filename) + existing_plugin = self._file_tracers.get(filename) if existing_plugin is not None and plugin_name != existing_plugin: raise CoverageException( "Conflicting plugin name for '%s': %r vs %r" % ( filename, existing_plugin, plugin_name, ) ) - self._plugins[filename] = plugin_name + self._file_tracers[filename] = plugin_name self._validate() @@ -340,8 +340,8 @@ class CoverageData(object): else: file_data['lines'] = self._lines - if self._plugins: - file_data['plugins'] = self._plugins + if self._file_tracers: + file_data['file_tracers'] = self._file_tracers # Write the data to the file. file_obj.write(self.GO_AWAY) @@ -358,7 +358,7 @@ class CoverageData(object): """Erase the data in this object.""" self._lines = {} self._arcs = {} - self._plugins = {} + self._file_tracers = {} self._validate() def update(self, other_data, aliases=None): @@ -375,16 +375,16 @@ class CoverageData(object): aliases = aliases or PathAliases() - # _plugins: only have a string, so they have to agree. + # _file_tracers: only have a string, so they have to agree. # Have to do these first, so that our examination of self._arcs and # self._lines won't be confused by data updated from other_data. for filename in other_data.measured_files(): - other_plugin = other_data.plugin_name(filename) + other_plugin = other_data.file_tracer(filename) filename = aliases.map(filename) - this_plugin = self.plugin_name(filename) + this_plugin = self.file_tracer(filename) if this_plugin is None: if other_plugin: - self._plugins[filename] = other_plugin + self._file_tracers[filename] = other_plugin elif this_plugin != other_plugin: raise CoverageException( "Conflicting plugin name for '%s': %r vs %r" % ( @@ -442,11 +442,13 @@ class CoverageData(object): "_arcs[%r] shouldn't be %r" % (fname, arcs) ) - # _plugins should have only non-empty strings as values. - for fname, plugin in iitems(self._plugins): - assert isinstance(fname, string_class), "Key in _plugins shouldn't be %r" % (fname,) + # _file_tracers should have only non-empty strings as values. + for fname, plugin in iitems(self._file_tracers): + assert isinstance(fname, string_class), ( + "Key in _file_tracers shouldn't be %r" % (fname,) + ) assert plugin and isinstance(plugin, string_class), ( - "_plugins[%r] shoudn't be %r" % (fname, plugin) + "_file_tracers[%r] shoudn't be %r" % (fname, plugin) ) def add_to_hash(self, filename, hasher): @@ -462,7 +464,7 @@ class CoverageData(object): hasher.update(sorted(self.arcs(filename))) else: hasher.update(sorted(self.lines(filename))) - hasher.update(self.plugin_name(filename)) + hasher.update(self.file_tracer(filename)) ## ## Internal diff --git a/coverage/tracer.c b/coverage/tracer.c index 11606ebd..5c08b392 100644 --- a/coverage/tracer.c +++ b/coverage/tracer.c @@ -107,7 +107,7 @@ typedef struct { PyObject * warn; PyObject * concur_id_func; PyObject * data; - PyObject * plugin_data; + PyObject * file_tracers; PyObject * should_trace_cache; PyObject * arcs; @@ -248,7 +248,7 @@ CTracer_dealloc(CTracer *self) Py_XDECREF(self->warn); Py_XDECREF(self->concur_id_func); Py_XDECREF(self->data); - Py_XDECREF(self->plugin_data); + Py_XDECREF(self->file_tracers); Py_XDECREF(self->should_trace_cache); DataStack_dealloc(self, &self->data_stack); @@ -612,7 +612,7 @@ CTracer_handle_call(CTracer *self, PyFrameObject *frame) /* If the disposition mentions a plugin, record that. */ if (file_tracer != Py_None) { - ret2 = PyDict_SetItem(self->plugin_data, tracename, plugin_name); + ret2 = PyDict_SetItem(self->file_tracers, tracename, plugin_name); if (ret2 < 0) { goto error; } @@ -1104,7 +1104,7 @@ CTracer_members[] = { { "data", T_OBJECT, offsetof(CTracer, data), 0, PyDoc_STR("The raw dictionary of trace data.") }, - { "plugin_data", T_OBJECT, offsetof(CTracer, plugin_data), 0, + { "file_tracers", T_OBJECT, offsetof(CTracer, file_tracers), 0, PyDoc_STR("Mapping from filename to plugin name.") }, { "should_trace_cache", T_OBJECT, offsetof(CTracer, should_trace_cache), 0, |