summaryrefslogtreecommitdiff
path: root/coverage/data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-08-10 16:15:00 -0400
committerNed Batchelder <ned@nedbatchelder.com>2018-08-10 16:15:00 -0400
commit90bb6a77e02cbac6a23723b5907d5f59d1db1b82 (patch)
tree35fcc2fc1063b0142985ca17149abbe83fdb5d09 /coverage/data.py
parent02b2bd8afe3cd171e4bd454ccf244f788ccded3c (diff)
downloadpython-coveragepy-git-90bb6a77e02cbac6a23723b5907d5f59d1db1b82.tar.gz
Move a common method outside the data classes
Diffstat (limited to 'coverage/data.py')
-rw-r--r--coverage/data.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/coverage/data.py b/coverage/data.py
index db9cd526..9c82ccef 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -641,20 +641,6 @@ class CoverageJsonData(object):
for key in val:
assert isinstance(key, string_class), "Key in _runs shouldn't be %r" % (key,)
- def add_to_hash(self, filename, hasher):
- """Contribute `filename`'s data to the `hasher`.
-
- `hasher` is a `coverage.misc.Hasher` instance to be updated with
- the file's data. It should only get the results data, not the run
- data.
-
- """
- if self._has_arcs():
- hasher.update(sorted(self.arcs(filename) or []))
- else:
- hasher.update(sorted(self.lines(filename) or []))
- hasher.update(self.file_tracer(filename))
-
##
## Internal
##
@@ -676,6 +662,21 @@ elif which == "sql":
CoverageData = CoverageSqliteData
+def add_data_to_hash(data, filename, hasher):
+ """Contribute `filename`'s data to the `hasher`.
+
+ `hasher` is a `coverage.misc.Hasher` instance to be updated with
+ the file's data. It should only get the results data, not the run
+ data.
+
+ """
+ if data.has_arcs():
+ hasher.update(sorted(data.arcs(filename) or []))
+ else:
+ hasher.update(sorted(data.lines(filename) or []))
+ hasher.update(data.file_tracer(filename))
+
+
def combine_parallel_data(data, aliases=None, data_paths=None, strict=False):
"""Combine a number of data files together.