5
5
from coverage .misc import NoSource
6
6
from coverage .misc import NotPython
7
7
8
- from .exception import CoverallsException
9
-
10
8
11
9
log = logging .getLogger ('coveralls.reporter' )
12
10
@@ -112,19 +110,7 @@ def report(self, cov, conf, morfs=None):
112
110
except ImportError : # coverage >= 5.0
113
111
return self .report5 (cov )
114
112
115
- units = None
116
- if hasattr (self .reporter , 'find_code_units' ):
117
- self .reporter .find_code_units (morfs )
118
- else :
119
- units = self .reporter .find_file_reporters (morfs )
120
-
121
- if units is None :
122
- if hasattr (self .reporter , 'code_units' ):
123
- units = self .reporter .code_units
124
- else :
125
- units = self .reporter .file_reporters
126
-
127
- for cu in units :
113
+ for cu in self .reporter .find_file_reporters (morfs ):
128
114
try :
129
115
_fn = self .reporter .coverage ._analyze # pylint: disable=W0212
130
116
analyzed = _fn (cu )
@@ -138,17 +124,6 @@ def report(self, cov, conf, morfs=None):
138
124
if (cu .should_be_python ()
139
125
and not self .reporter .config .ignore_errors ):
140
126
log .warning ('Source file is not python %s' , cu .filename )
141
- except KeyError :
142
- version = [int (x ) for x in __version__ .split ('.' )]
143
- cov40 = version [0 ] == 4 and version [1 ] < 1
144
- if cov40 :
145
- raise CoverallsException (
146
- 'Old (<4.1) versions of coverage.py do not work '
147
- 'consistently on new versions of Python. Please '
148
- 'upgrade your coverage.py.'
149
- )
150
-
151
- raise
152
127
153
128
return self .coverage
154
129
@@ -207,27 +182,15 @@ def get_arcs(analysis):
207
182
208
183
def parse_file (self , cu , analysis ):
209
184
"""Generate data for single file."""
210
- if hasattr (analysis , 'parser' ):
211
- filename = cu .file_locator .relative_filename (cu .filename )
212
- source_lines = analysis .parser .lines
213
- with cu .source_file () as source_file :
214
- source = source_file .read ()
215
- else :
216
- if hasattr (cu , 'relative_filename' ):
217
- filename = cu .relative_filename ()
218
- else :
219
- filename = analysis .coverage .file_locator .relative_filename (
220
- cu .filename )
185
+ filename = cu .relative_filename ()
186
+ # ensure results are properly merged between platforms
187
+ posix_filename = filename .replace (os .path .sep , '/' )
221
188
222
- token_lines = analysis .file_reporter .source_token_lines ()
223
- source_lines = list (enumerate (token_lines ))
224
- source = analysis .file_reporter .source ()
189
+ source = analysis .file_reporter .source ()
225
190
191
+ token_lines = analysis .file_reporter .source_token_lines ()
226
192
coverage_lines = [self .get_hits (i , analysis )
227
- for i in range (1 , len (source_lines ) + 1 )]
228
-
229
- # ensure results are properly merged between platforms
230
- posix_filename = filename .replace (os .path .sep , '/' )
193
+ for i , _ in enumerate (token_lines , 1 )]
231
194
232
195
results = {
233
196
'name' : posix_filename ,
0 commit comments