summaryrefslogtreecommitdiff
path: root/coverage/data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2011-08-21 14:02:20 -0400
committerNed Batchelder <ned@nedbatchelder.com>2011-08-21 14:02:20 -0400
commit5f6930a60d495c8433b64529ac2ec321d9f1f13b (patch)
tree7818acb429a18fb812075624f952dd1a2bb6b161 /coverage/data.py
parent9e122f315a3f1c27aed107a8c8035b7dc9aa29bd (diff)
downloadpython-coveragepy-5f6930a60d495c8433b64529ac2ec321d9f1f13b.tar.gz
The machinery to map paths through aliases for merging coverage data from disparate machines. Part of fixing #17.
Diffstat (limited to 'coverage/data.py')
-rw-r--r--coverage/data.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/coverage/data.py b/coverage/data.py
index 3263cb3..1cc4c95 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -1,8 +1,10 @@
"""Coverage data for Coverage."""
-import os
+import fnmatch, os, re
from coverage.backward import pickle, sorted # pylint: disable=W0622
+from coverage.files import PathAliases
+from coverage.misc import CoverageException
class CoverageData(object):
@@ -169,13 +171,17 @@ class CoverageData(object):
pass
return lines, arcs
- def combine_parallel_data(self):
+ def combine_parallel_data(self, aliases=None):
"""Combine a number of data files together.
Treat `self.filename` as a file prefix, and combine the data from all
of the data files starting with that prefix plus a dot.
+ If `aliases` is provided, it's a PathAliases object that is used to
+ re-map paths to match the local machine's.
+
"""
+ aliases = aliases or PathAliases()
data_dir, local = os.path.split(self.filename)
localdot = local + '.'
for f in os.listdir(data_dir or '.'):
@@ -183,8 +189,10 @@ class CoverageData(object):
full_path = os.path.join(data_dir, f)
new_lines, new_arcs = self._read_file(full_path)
for filename, file_data in new_lines.items():
+ filename = aliases.map(filename)
self.lines.setdefault(filename, {}).update(file_data)
for filename, file_data in new_arcs.items():
+ filename = aliases.map(filename)
self.arcs.setdefault(filename, {}).update(file_data)
if f != local:
os.remove(full_path)