Sat, 10 Oct 2015 12:44:52 +0200
Merged with coverage.py update.
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
1 | # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
2 | # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
4 | """Coverage data for coverage.py.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
5 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
6 | import glob |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
7 | import json |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
8 | import optparse |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | import os |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
10 | import os.path |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
11 | import random |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
12 | import re |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
13 | import socket |
4490
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
14 | import sys |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
16 | from coverage import env |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
17 | from coverage.backward import iitems, string_class |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
18 | from coverage.debug import _TEST_NAME_FILE |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
19 | from coverage.files import PathAliases |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
20 | from coverage.misc import CoverageException, file_be_gone |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
23 | class CoverageData(object): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """Manages collected coverage data, including file storage. |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
25 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
26 | This class is the public supported API to the data coverage.py collects |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
27 | during program execution. It includes information about what code was |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
28 | executed. It does not include information from the analysis phase, to |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
29 | determine what lines could have been executed, or what lines were not |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
30 | executed. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
31 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
32 | .. note:: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
33 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
34 | The file format is not documented or guaranteed. It will change in |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
35 | the future, in possibly complicated ways. Do not read coverage.py |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
36 | data files directly. Use this API to avoid disruption. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
37 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
38 | There are a number of kinds of data that can be collected: |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
39 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
40 | * **lines**: the line numbers of source lines that were executed. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
41 | These are always available. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
42 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
43 | * **arcs**: pairs of source and destination line numbers for transitions |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
44 | between source lines. These are only available if branch coverage was |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
45 | used. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
46 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
47 | * **file tracer names**: the module names of the file tracer plugins that |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
48 | handled each file in the data. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
49 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
50 | * **run information**: information about the program execution. This is |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
51 | written during "coverage run", and then accumulated during "coverage |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
52 | combine". |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
54 | Lines, arcs, and file tracer names are stored for each source file. File |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
55 | names in this API are case-sensitive, even on platforms with |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
56 | case-insensitive file systems. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
57 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
58 | To read a coverage.py data file, use :meth:`read_file`, or |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
59 | :meth:`read_fileobj` if you have an already-opened file. You can then |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
60 | access the line, arc, or file tracer data with :meth:`lines`, :meth:`arcs`, |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
61 | or :meth:`file_tracer`. Run information is available with |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
62 | :meth:`run_infos`. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
63 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
64 | The :meth:`has_arcs` method indicates whether arc data is available. You |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
65 | can get a list of the files in the data with :meth:`measured_files`. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
66 | A summary of the line data is available from :meth:`line_counts`. As with |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
67 | most Python containers, you can determine if there is any data at all by |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
68 | using this object as a boolean value. |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
69 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
70 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
71 | Most data files will be created by coverage.py itself, but you can use |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
72 | methods here to create data files if you like. The :meth:`add_lines`, |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
73 | :meth:`add_arcs`, and :meth:`add_file_tracers` methods add data, in ways |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
74 | that are convenient for coverage.py. The :meth:`add_run_info` method adds |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
75 | key-value pairs to the run information. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
76 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
77 | To add a file without any measured data, use :meth:`touch_file`. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
78 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
79 | You write to a named file with :meth:`write_file`, or to an already opened |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
80 | file with :meth:`write_fileobj`. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
81 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
82 | You can clear the data in memory with :meth:`erase`. Two data collections |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
83 | can be combined by using :meth:`update` on one :class:`CoverageData`, |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
84 | passing it the other. |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
85 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | """ |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
87 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
88 | # The data file format is JSON, with these keys: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
89 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
90 | # * lines: a dict mapping file names to lists of line numbers |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
91 | # executed:: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
92 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
93 | # { "file1": [17,23,45], "file2": [1,2,3], ... } |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
94 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
95 | # * arcs: a dict mapping file names to lists of line number pairs:: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
96 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
97 | # { "file1": [[17,23], [17,25], [25,26]], ... } |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
98 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
99 | # * file_tracers: a dict mapping file names to plugin names:: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
100 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
101 | # { "file1": "django.coverage", ... } |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
102 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
103 | # * runs: a list of dicts of information about the coverage.py runs |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
104 | # contributing to the data:: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
105 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
106 | # [ { "brief_sys": "CPython 2.7.10 Darwin" }, ... ] |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
107 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
108 | # Only one of `lines` or `arcs` will be present: with branch coverage, data |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
109 | # is stored as arcs. Without branch coverage, it is stored as lines. The |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
110 | # line data is easily recovered from the arcs: it is all the first elements |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
111 | # of the pairs that are greater than zero. |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
112 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
113 | def __init__(self, debug=None): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
114 | """Create a CoverageData. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | |
3495
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
116 | `debug` is a `DebugControl` object for writing debug messages. |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
117 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | """ |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
119 | self._debug = debug |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | # A map from canonical Python source file name to a dictionary in |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | # which there's an entry for each line number that has been |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | # executed: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | # |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
125 | # { 'filename1.py': [12, 47, 1001], ... } |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | # |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
127 | self._lines = None |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
128 | |
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
129 | # A map from canonical Python source file name to a dictionary with an |
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
130 | # entry for each pair of line numbers forming an arc: |
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
131 | # |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
132 | # { 'filename1.py': [(12,14), (47,48), ... ], ... } |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
133 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
134 | self._arcs = None |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
135 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
136 | # A map from canonical source file name to a plugin module name: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
137 | # |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
138 | # { 'filename1.py': 'django.coverage', ... } |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
139 | # |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
140 | self._file_tracers = {} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
141 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
142 | # A list of dicts of information about the coverage.py runs. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
143 | self._runs = [] |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
144 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
145 | def __repr__(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
146 | return "<{klass} lines={lines} arcs={arcs} tracers={tracers} runs={runs}>".format( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
147 | klass=self.__class__.__name__, |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
148 | lines="None" if self._lines is None else "{{{0}}}".format(len(self._lines)), |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
149 | arcs="None" if self._arcs is None else "{{{0}}}".format(len(self._arcs)), |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
150 | tracers="{{{0}}}".format(len(self._file_tracers)), |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
151 | runs="[{0}]".format(len(self._runs)), |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
152 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
153 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
154 | ## |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
155 | ## Reading data |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
156 | ## |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
157 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
158 | def has_arcs(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
159 | """Does this data have arcs? |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
160 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
161 | Arc data is only available if branch coverage was used during |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
162 | collection. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
163 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
164 | Returns a boolean. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
165 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
166 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
167 | return self._has_arcs() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
168 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
169 | def lines(self, filename): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
170 | """Get the list of lines executed for a file. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
171 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
172 | If the file was not measured, returns None. A file might be measured, |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
173 | and have no lines executed, in which case an empty list is returned. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
174 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
175 | If the file was executed, returns a list of integers, the line numbers |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
176 | executed in the file. The list is in no particular order. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
177 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
178 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
179 | if self._arcs is not None: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
180 | if filename in self._arcs: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
181 | return [s for s, __ in self._arcs[filename] if s > 0] |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
182 | elif self._lines is not None: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
183 | if filename in self._lines: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
184 | return self._lines[filename] |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
185 | return None |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
186 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
187 | def arcs(self, filename): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
188 | """Get the list of arcs executed for a file. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
189 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
190 | If the file was not measured, returns None. A file might be measured, |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
191 | and have no arcs executed, in which case an empty list is returned. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
192 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
193 | If the file was executed, returns a list of 2-tuples of integers. Each |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
194 | pair is a starting line number and an ending line number for a |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
195 | transition from one line to another. The list is in no particular |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
196 | order. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
197 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
198 | Negative numbers have special meaning. If the starting line number is |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
199 | -N, it represents an entry to the code object that starts at line N. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
200 | If the ending ling number is -N, it's an exit from the code object that |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
201 | starts at line N. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
202 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
203 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
204 | if self._arcs is not None: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
205 | if filename in self._arcs: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
206 | return self._arcs[filename] |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
207 | return None |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
208 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
209 | def file_tracer(self, filename): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
210 | """Get the plugin name of the file tracer for a file. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
211 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
212 | Returns the name of the plugin that handles this file. If the file was |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
213 | measured, but didn't use a plugin, then "" is returned. If the file |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
214 | was not measured, then None is returned. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
215 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
216 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
217 | # Because the vast majority of files involve no plugin, we don't store |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
218 | # them explicitly in self._file_tracers. Check the measured data |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
219 | # instead to see if it was a known file with no plugin. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
220 | if filename in (self._arcs or self._lines or {}): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
221 | return self._file_tracers.get(filename, "") |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
222 | return None |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
223 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
224 | def run_infos(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
225 | """Return the list of dicts of run information. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
226 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
227 | For data collected during a single run, this will be a one-element |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
228 | list. If data has been combined, there will be one element for each |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
229 | original data file. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
230 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
231 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
232 | return self._runs |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
233 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
234 | def measured_files(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
235 | """A list of all files that had been measured.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
236 | return list(self._arcs or self._lines or {}) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
237 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
238 | def line_counts(self, fullpath=False): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
239 | """Return a dict summarizing the line coverage data. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
240 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
241 | Keys are based on the file names, and values are the number of executed |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
242 | lines. If `fullpath` is true, then the keys are the full pathnames of |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
243 | the files, otherwise they are the basenames of the files. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
244 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
245 | Returns a dict mapping file names to counts of lines. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
246 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
247 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
248 | summ = {} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
249 | if fullpath: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
250 | filename_fn = lambda f: f |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
251 | else: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
252 | filename_fn = os.path.basename |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
253 | for filename in self.measured_files(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
254 | summ[filename_fn(filename)] = len(self.lines(filename)) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
255 | return summ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
256 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
257 | def __nonzero__(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
258 | return bool(self._lines or self._arcs) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
259 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
260 | __bool__ = __nonzero__ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
261 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
262 | def read_fileobj(self, file_obj): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
263 | """Read the coverage data from the given file object. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
264 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
265 | Should only be used on an empty CoverageData object. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
266 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
267 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
268 | data = self._read_raw_data(file_obj) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
269 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
270 | self._lines = self._arcs = None |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
271 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
272 | if 'lines' in data: |
4490
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
273 | self._lines = dict( |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
274 | (fname.encode(sys.getfilesystemencoding()), linenos) |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
275 | for fname, linenos in iitems(data['lines']) |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
276 | ) |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
277 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
278 | if 'arcs' in data: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
279 | self._arcs = dict( |
4490
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
280 | (fname.encode(sys.getfilesystemencoding()), |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
281 | [tuple(pair) for pair in arcs]) |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
282 | for fname, arcs in iitems(data['arcs']) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
283 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
284 | self._file_tracers = data.get('file_tracers', {}) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
285 | self._runs = data.get('runs', []) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
286 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
287 | self._validate() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
288 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
289 | def read_file(self, filename): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
290 | """Read the coverage data from `filename` into this object.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
291 | if self._debug and self._debug.should('dataio'): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
292 | self._debug.write("Reading data from %r" % (filename,)) |
4490
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
293 | with self._open_for_reading(filename) as f: |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
294 | self.read_fileobj(f) |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
295 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
296 | _GO_AWAY = "!coverage.py: This is a private format, don't read it directly!" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
297 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
298 | @classmethod |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
299 | def _open_for_reading(cls, filename): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
300 | """Open a file appropriately for reading data.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
301 | return open(filename, "r") |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
302 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
303 | @classmethod |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
304 | def _read_raw_data(cls, file_obj): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
305 | """Read the raw data from a file object.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
306 | go_away = file_obj.read(len(cls._GO_AWAY)) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
307 | if go_away != cls._GO_AWAY: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
308 | raise CoverageException("Doesn't seem to be a coverage.py data file") |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
309 | return json.load(file_obj) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
310 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
311 | @classmethod |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
312 | def _read_raw_data_file(cls, filename): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
313 | """Read the raw data from a file, for debugging.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
314 | with cls._open_for_reading(filename) as f: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
315 | return cls._read_raw_data(f) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
316 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
317 | ## |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
318 | ## Writing data |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
319 | ## |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
320 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
321 | def add_lines(self, line_data): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
322 | """Add measured line data. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
323 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
324 | `line_data` is a dictionary mapping file names to dictionaries:: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
325 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
326 | { filename: { lineno: None, ... }, ...} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
327 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
328 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
329 | if self._debug and self._debug.should('dataop'): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
330 | self._debug.write("Adding lines: %d files, %d lines total" % ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
331 | len(line_data), sum(len(lines) for lines in line_data.values()) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
332 | )) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
333 | if self._has_arcs(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
334 | raise CoverageException("Can't add lines to existing arc data") |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
335 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
336 | if self._lines is None: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
337 | self._lines = {} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
338 | for filename, linenos in iitems(line_data): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
339 | if filename in self._lines: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
340 | new_linenos = set(self._lines[filename]) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
341 | new_linenos.update(linenos) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
342 | linenos = new_linenos |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
343 | self._lines[filename] = list(linenos) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
344 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
345 | self._validate() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
346 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
347 | def add_arcs(self, arc_data): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
348 | """Add measured arc data. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
349 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
350 | `arc_data` is a dictionary mapping file names to dictionaries:: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
351 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
352 | { filename: { (l1,l2): None, ... }, ...} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
353 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
354 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
355 | if self._debug and self._debug.should('dataop'): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
356 | self._debug.write("Adding arcs: %d files, %d arcs total" % ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
357 | len(arc_data), sum(len(arcs) for arcs in arc_data.values()) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
358 | )) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
359 | if self._has_lines(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
360 | raise CoverageException("Can't add arcs to existing line data") |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
361 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
362 | if self._arcs is None: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
363 | self._arcs = {} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
364 | for filename, arcs in iitems(arc_data): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
365 | if filename in self._arcs: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
366 | new_arcs = set(self._arcs[filename]) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
367 | new_arcs.update(arcs) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
368 | arcs = new_arcs |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
369 | self._arcs[filename] = list(arcs) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
370 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
371 | self._validate() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
372 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
373 | def add_file_tracers(self, file_tracers): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
374 | """Add per-file plugin information. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
375 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
376 | `file_tracers` is { filename: plugin_name, ... } |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
377 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
378 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
379 | if self._debug and self._debug.should('dataop'): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
380 | self._debug.write("Adding file tracers: %d files" % (len(file_tracers),)) |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
381 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
382 | existing_files = self._arcs or self._lines or {} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
383 | for filename, plugin_name in iitems(file_tracers): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
384 | if filename not in existing_files: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
385 | raise CoverageException( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
386 | "Can't add file tracer data for unmeasured file '%s'" % (filename,) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
387 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
388 | existing_plugin = self._file_tracers.get(filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
389 | if existing_plugin is not None and plugin_name != existing_plugin: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
390 | raise CoverageException( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
391 | "Conflicting file tracer name for '%s': %r vs %r" % ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
392 | filename, existing_plugin, plugin_name, |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
393 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
394 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
395 | self._file_tracers[filename] = plugin_name |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
396 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
397 | self._validate() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
398 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
399 | def add_run_info(self, **kwargs): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
400 | """Add information about the run. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
401 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
402 | Keywords are arbitrary, and are stored in the run dictionary. Values |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
403 | must be JSON serializable. You may use this function more than once, |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
404 | but repeated keywords overwrite each other. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
405 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
406 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
407 | if self._debug and self._debug.should('dataop'): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
408 | self._debug.write("Adding run info: %r" % (kwargs,)) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
409 | if not self._runs: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
410 | self._runs = [{}] |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
411 | self._runs[0].update(kwargs) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
412 | self._validate() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
413 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
414 | def touch_file(self, filename): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
415 | """Ensure that `filename` appears in the data, empty if needed.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
416 | if self._debug and self._debug.should('dataop'): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
417 | self._debug.write("Touching %r" % (filename,)) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
418 | if not self._has_arcs() and not self._has_lines(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
419 | raise CoverageException("Can't touch files in an empty CoverageData") |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
420 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
421 | if self._has_arcs(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
422 | where = self._arcs |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
423 | else: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
424 | where = self._lines |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
425 | where.setdefault(filename, []) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
426 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
427 | self._validate() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
428 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
429 | def write_fileobj(self, file_obj): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
430 | """Write the coverage data to `file_obj`.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
431 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
432 | # Create the file data. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
433 | file_data = {} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
434 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
435 | if self._has_arcs(): |
4490
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
436 | file_data['arcs'] = dict( |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
437 | (fname.decode(sys.getfilesystemencoding()), |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
438 | [tuple(pair) for pair in self._arcs]) |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
439 | for fname, arcs in iitems(data['arcs']) |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
440 | ) |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
441 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
442 | if self._has_lines(): |
4490
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
443 | file_data['lines'] = dict( |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
444 | (fname.decode(sys.getfilesystemencoding()), linenos) |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
445 | for fname, linenos in iitems(self._lines) |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
446 | ) |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
447 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
448 | if self._file_tracers: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
449 | file_data['file_tracers'] = self._file_tracers |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
450 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
451 | if self._runs: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
452 | file_data['runs'] = self._runs |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
453 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
454 | # Write the data to the file. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
455 | file_obj.write(self._GO_AWAY) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
456 | json.dump(file_data, file_obj) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
457 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
458 | def write_file(self, filename): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
459 | """Write the coverage data to `filename`.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
460 | if self._debug and self._debug.should('dataio'): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
461 | self._debug.write("Writing data to %r" % (filename,)) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
462 | with open(filename, 'w') as fdata: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
463 | self.write_fileobj(fdata) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
464 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
465 | def erase(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
466 | """Erase the data in this object.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
467 | self._lines = None |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
468 | self._arcs = None |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
469 | self._file_tracers = {} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
470 | self._runs = [] |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
471 | self._validate() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
472 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
473 | def update(self, other_data, aliases=None): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
474 | """Update this data with data from another `CoverageData`. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
475 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
476 | If `aliases` is provided, it's a `PathAliases` object that is used to |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
477 | re-map paths to match the local machine's. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
478 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
479 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
480 | if self._has_lines() and other_data._has_arcs(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
481 | raise CoverageException("Can't combine arc data with line data") |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
482 | if self._has_arcs() and other_data._has_lines(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
483 | raise CoverageException("Can't combine line data with arc data") |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
484 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
485 | aliases = aliases or PathAliases() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
486 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
487 | # _file_tracers: only have a string, so they have to agree. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
488 | # Have to do these first, so that our examination of self._arcs and |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
489 | # self._lines won't be confused by data updated from other_data. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
490 | for filename in other_data.measured_files(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
491 | other_plugin = other_data.file_tracer(filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
492 | filename = aliases.map(filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
493 | this_plugin = self.file_tracer(filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
494 | if this_plugin is None: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
495 | if other_plugin: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
496 | self._file_tracers[filename] = other_plugin |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
497 | elif this_plugin != other_plugin: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
498 | raise CoverageException( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
499 | "Conflicting file tracer name for '%s': %r vs %r" % ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
500 | filename, this_plugin, other_plugin, |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
501 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
502 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
503 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
504 | # _runs: add the new runs to these runs. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
505 | self._runs.extend(other_data._runs) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
506 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
507 | # _lines: merge dicts. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
508 | if other_data._has_lines(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
509 | if self._lines is None: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
510 | self._lines = {} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
511 | for filename, file_lines in iitems(other_data._lines): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
512 | filename = aliases.map(filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
513 | if filename in self._lines: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
514 | lines = set(self._lines[filename]) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
515 | lines.update(file_lines) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
516 | file_lines = list(lines) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
517 | self._lines[filename] = file_lines |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
518 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
519 | # _arcs: merge dicts. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
520 | if other_data._has_arcs(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
521 | if self._arcs is None: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
522 | self._arcs = {} |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
523 | for filename, file_arcs in iitems(other_data._arcs): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
524 | filename = aliases.map(filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
525 | if filename in self._arcs: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
526 | arcs = set(self._arcs[filename]) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
527 | arcs.update(file_arcs) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
528 | file_arcs = list(arcs) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
529 | self._arcs[filename] = file_arcs |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
530 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
531 | self._validate() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
532 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
533 | ## |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
534 | ## Miscellaneous |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
535 | ## |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
536 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
537 | def _validate(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
538 | """If we are in paranoid mode, validate that everything is right.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
539 | if env.TESTING: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
540 | self._validate_invariants() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
541 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
542 | def _validate_invariants(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
543 | """Validate internal invariants.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
544 | # Only one of _lines or _arcs should exist. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
545 | assert not(self._has_lines() and self._has_arcs()), ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
546 | "Shouldn't have both _lines and _arcs" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
547 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
548 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
549 | # _lines should be a dict of lists of ints. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
550 | if self._has_lines(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
551 | for fname, lines in iitems(self._lines): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
552 | assert isinstance(fname, string_class), "Key in _lines shouldn't be %r" % (fname,) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
553 | assert all(isinstance(x, int) for x in lines), ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
554 | "_lines[%r] shouldn't be %r" % (fname, lines) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
555 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
556 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
557 | # _arcs should be a dict of lists of pairs of ints. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
558 | if self._has_arcs(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
559 | for fname, arcs in iitems(self._arcs): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
560 | assert isinstance(fname, string_class), "Key in _arcs shouldn't be %r" % (fname,) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
561 | assert all(isinstance(x, int) and isinstance(y, int) for x, y in arcs), ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
562 | "_arcs[%r] shouldn't be %r" % (fname, arcs) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
563 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
564 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
565 | # _file_tracers should have only non-empty strings as values. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
566 | for fname, plugin in iitems(self._file_tracers): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
567 | assert isinstance(fname, string_class), ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
568 | "Key in _file_tracers shouldn't be %r" % (fname,) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
569 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
570 | assert plugin and isinstance(plugin, string_class), ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
571 | "_file_tracers[%r] shoudn't be %r" % (fname, plugin) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
572 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
573 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
574 | # _runs should be a list of dicts. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
575 | for val in self._runs: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
576 | assert isinstance(val, dict) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
577 | for key in val: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
578 | assert isinstance(key, string_class), "Key in _runs shouldn't be %r" % (key,) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
579 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
580 | def add_to_hash(self, filename, hasher): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
581 | """Contribute `filename`'s data to the `hasher`. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
582 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
583 | `hasher` is a :class:`coverage.misc.Hasher` instance to be updated with |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
584 | the file's data. It should only get the results data, not the run |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
585 | data. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
586 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
587 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
588 | if self._has_arcs(): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
589 | hasher.update(sorted(self.arcs(filename) or [])) |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
590 | else: |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
591 | hasher.update(sorted(self.lines(filename) or [])) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
592 | hasher.update(self.file_tracer(filename)) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
593 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
594 | ## |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
595 | ## Internal |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
596 | ## |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
597 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
598 | def _has_lines(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
599 | """Do we have data in self._lines?""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
600 | return self._lines is not None |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
601 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
602 | def _has_arcs(self): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
603 | """Do we have data in self._arcs?""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
604 | return self._arcs is not None |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
605 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
606 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
607 | class CoverageDataFiles(object): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
608 | """Manage the use of coverage data files.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
609 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
610 | def __init__(self, basename=None): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
611 | """Create a CoverageDataFiles to manage data files. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
612 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
613 | `basename` is the name of the file to use for storing data. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
614 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
615 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
616 | # Construct the file name that will be used for data storage. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
617 | self.filename = os.path.abspath(basename or ".coverage") |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
618 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
619 | def erase(self, parallel=False): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
620 | """Erase the data from the file storage. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
621 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
622 | If `parallel` is true, then also deletes data files created from the |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
623 | basename by parallel-mode. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
624 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
625 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
626 | file_be_gone(self.filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
627 | if parallel: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
628 | data_dir, local = os.path.split(self.filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
629 | localdot = local + '.*' |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
630 | pattern = os.path.join(os.path.abspath(data_dir), localdot) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
631 | for filename in glob.glob(pattern): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
632 | file_be_gone(filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
633 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
634 | def read(self, data): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
635 | """Read the coverage data.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
636 | if os.path.exists(self.filename): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
637 | data.read_file(self.filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
638 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
639 | def write(self, data, suffix=None): |
3495
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
640 | """Write the collected coverage data to a file. |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
641 | |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
642 | `suffix` is a suffix to append to the base file name. This can be used |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
643 | for multiple or parallel execution, so that many coverage data files |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
644 | can exist simultaneously. A dot will be used to join the base name and |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
645 | the suffix. |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
646 | |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
647 | """ |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
648 | filename = self.filename |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
649 | if suffix is True: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
650 | # If data_suffix was a simple true value, then make a suffix with |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
651 | # plenty of distinguishing information. We do this here in |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
652 | # `save()` at the last minute so that the pid will be correct even |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
653 | # if the process forks. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
654 | extra = "" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
655 | if _TEST_NAME_FILE: # pragma: debugging |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
656 | with open(_TEST_NAME_FILE) as f: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
657 | test_name = f.read() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
658 | extra = "." + test_name |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
659 | suffix = "%s%s.%s.%06d" % ( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
660 | socket.gethostname(), extra, os.getpid(), |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
661 | random.randint(0, 999999) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
662 | ) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
663 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
664 | if suffix: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
665 | filename += "." + suffix |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
666 | data.write_file(filename) |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
667 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
668 | def combine_parallel_data(self, data, aliases=None, data_paths=None): |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
669 | """Combine a number of data files together. |
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
670 | |
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
671 | Treat `self.filename` as a file prefix, and combine the data from all |
3495
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
672 | of the data files starting with that prefix plus a dot. |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
673 | |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
674 | If `aliases` is provided, it's a `PathAliases` object that is used to |
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
675 | re-map paths to match the local machine's. |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
676 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
677 | If `data_paths` is provided, it is a list of directories or files to |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
678 | combine. Directories are searched for files that start with |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
679 | `self.filename` plus dot as a prefix, and those files are combined. |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
680 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
681 | If `data_paths` is not provided, then the directory portion of |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
682 | `self.filename` is used as the directory to search for data files. |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
683 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
684 | Every data file found and combined is then deleted from disk. |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
685 | |
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
686 | """ |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
687 | # Because of the os.path.abspath in the constructor, data_dir will |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
688 | # never be an empty string. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
689 | data_dir, local = os.path.split(self.filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
690 | localdot = local + '.*' |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
691 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
692 | data_paths = data_paths or [data_dir] |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
693 | files_to_combine = [] |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
694 | for p in data_paths: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
695 | if os.path.isfile(p): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
696 | files_to_combine.append(os.path.abspath(p)) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
697 | elif os.path.isdir(p): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
698 | pattern = os.path.join(os.path.abspath(p), localdot) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
699 | files_to_combine.extend(glob.glob(pattern)) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
700 | else: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
701 | raise CoverageException("Couldn't combine from non-existent path '%s'" % (p,)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
702 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
703 | for f in files_to_combine: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
704 | new_data = CoverageData() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
705 | new_data.read_file(f) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
706 | data.update(new_data, aliases=aliases) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
707 | file_be_gone(f) |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
708 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
709 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
710 | def canonicalize_json_data(data): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
711 | """Canonicalize our JSON data so it can be compared.""" |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
712 | for fname, lines in iitems(data.get('lines', {})): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
713 | data['lines'][fname] = sorted(lines) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
714 | for fname, arcs in iitems(data.get('arcs', {})): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
715 | data['arcs'][fname] = sorted(arcs) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
716 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
717 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
718 | def pretty_data(data): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
719 | """Format data as JSON, but as nicely as possible. |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
720 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
721 | Returns a string. |
3495
fac17a82b431
updated coverage to 3.7.1
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
790
diff
changeset
|
722 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
723 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
724 | # Start with a basic JSON dump. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
725 | out = json.dumps(data, indent=4, sort_keys=True) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
726 | # But pairs of numbers shouldn't be split across lines... |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
727 | out = re.sub(r"\[\s+(-?\d+),\s+(-?\d+)\s+]", r"[\1, \2]", out) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
728 | # Trailing spaces mess with tests, get rid of them. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
729 | out = re.sub(r"(?m)\s+$", "", out) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
730 | return out |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
731 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
732 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
733 | def debug_main(args): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
734 | """Dump the raw data from data files. |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
735 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
736 | Run this as:: |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
737 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
738 | $ python -m coverage.data [FILE] |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
739 | |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
740 | """ |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
741 | parser = optparse.OptionParser() |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
742 | parser.add_option( |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
743 | "-c", "--canonical", action="store_true", |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
744 | help="Sort data into a canonical order", |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
745 | ) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
746 | options, args = parser.parse_args(args) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
747 | |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
748 | for filename in (args or [".coverage"]): |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
749 | print("--- {0} ------------------------------".format(filename)) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
750 | data = CoverageData._read_raw_data_file(filename) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
751 | if options.canonical: |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
752 | canonicalize_json_data(data) |
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
753 | print(pretty_data(data)) |
31
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
754 | |
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
755 | |
744cd0b4b8cd
Updated coverage.py to version 3.2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
756 | if __name__ == '__main__': |
4489
d0d6e4ad31bd
Updated coverage to 4.0 (breaks with Python 3.2 support).
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4385
diff
changeset
|
757 | debug_main(sys.argv[1:]) |
4490
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
758 | |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
759 | # |
3f58261e7bb1
coverage fix for unicode problems in path names.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
4489
diff
changeset
|
760 | # eflag: FileType = Python2 |