summaryrefslogtreecommitdiff
path: root/coverage/data.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-12-02 07:27:14 -0500
committerNed Batchelder <ned@nedbatchelder.com>2009-12-02 07:27:14 -0500
commit968fc008e4c0453ef05aa211e85e202e7b1d2342 (patch)
tree91ae38367181a9ee0dda9ed22aa832031ca4c3d7 /coverage/data.py
parent007a4a1ba529e2913357387c1f42b6028860fe98 (diff)
downloadpython-coveragepy-git-968fc008e4c0453ef05aa211e85e202e7b1d2342.tar.gz
Massive eol whitespace clean-up.
Diffstat (limited to 'coverage/data.py')
-rw-r--r--coverage/data.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/coverage/data.py b/coverage/data.py
index 452ce73d..11c7c01d 100644
--- a/coverage/data.py
+++ b/coverage/data.py
@@ -7,20 +7,20 @@ from coverage.backward import pickle, sorted # pylint: disable-msg=W0622
class CoverageData(object):
"""Manages collected coverage data, including file storage.
-
+
The data file format is a pickled dict, with these keys:
-
+
* collector: a string identifying the collecting software
* lines: a dict mapping filenames to sorted lists of line numbers
executed:
{ 'file1': [17,23,45], 'file2': [1,2,3], ... }
-
+
* arcs: a dict mapping filenames to sorted lists of line number pairs:
{ 'file1': [(17,23), (17,25), (25,26)], ... }
"""
-
+
# Name of the data file (unless environment variable is set).
filename_default = ".coverage"
@@ -29,9 +29,9 @@ class CoverageData(object):
def __init__(self, basename=None, suffix=None, collector=None):
"""Create a CoverageData.
-
+
`basename` is the name of the file to use for storing data.
-
+
`suffix` is a suffix to append to the base file name. This can be used
for multiple or parallel execution, so that many coverage data files
can exist simultaneously.
@@ -40,7 +40,7 @@ class CoverageData(object):
"""
self.collector = collector
-
+
self.use_file = True
# Construct the filename that will be used for data file storage, if we
@@ -61,14 +61,14 @@ class CoverageData(object):
# }
#
self.lines = {}
-
+
# A map from canonical Python source file name to a dictionary with an
# entry for each pair of line numbers forming an arc:
#
# { filename: { (l1,l2): None, ... }, ...}
#
self.arcs = {}
-
+
def usefile(self, use_file=True):
"""Set whether or not to use a disk file for data."""
self.use_file = use_file
@@ -92,7 +92,7 @@ class CoverageData(object):
os.remove(self.filename)
self.lines = {}
self.arcs = {}
-
+
def line_data(self):
"""Return the map from filenames to lists of line numbers executed."""
return dict(
@@ -104,11 +104,11 @@ class CoverageData(object):
return dict(
[(f, sorted(amap.keys())) for f, amap in self.arcs.items()]
)
-
+
def write_file(self, filename):
"""Write the coverage data to `filename`."""
- # Create the file data.
+ # Create the file data.
data = {}
data['lines'] = self.line_data()
@@ -141,10 +141,10 @@ class CoverageData(object):
def _read_file(self, filename):
"""Return the stored coverage data from the given file.
-
+
Returns two values, suitable for assigning to `self.lines` and
`self.arcs`.
-
+
"""
lines = {}
arcs = {}
@@ -167,10 +167,10 @@ class CoverageData(object):
def combine_parallel_data(self):
"""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.
-
+
"""
data_dir, local = os.path.split(self.filename)
for f in os.listdir(data_dir or '.'):
@@ -184,18 +184,18 @@ class CoverageData(object):
def add_line_data(self, line_data):
"""Add executed line data.
-
+
`line_data` is { filename: { lineno: None, ... }, ...}
-
+
"""
for filename, linenos in line_data.items():
self.lines.setdefault(filename, {}).update(linenos)
def add_arc_data(self, arc_data):
"""Add measured arc data.
-
+
`arc_data` is { filename: { (l1,l2): None, ... }, ...}
-
+
"""
for filename, arcs in arc_data.items():
self.arcs.setdefault(filename, {}).update(arcs)
@@ -206,7 +206,7 @@ class CoverageData(object):
def executed_lines(self, filename):
"""A map containing all the line numbers executed in `filename`.
-
+
If `filename` hasn't been collected at all (because it wasn't executed)
then return an empty map.
@@ -219,11 +219,11 @@ class CoverageData(object):
def summary(self, fullpath=False):
"""Return a dict summarizing the coverage data.
-
+
Keys are based on the filenames, and values are the number of executed
lines. If `fullpath` is true, then the keys are the full pathnames of
the files, otherwise they are the basenames of the files.
-
+
"""
summ = {}
if fullpath: