Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1062d3c

Browse files
committed
process path aliases in run
1 parentebb6b39 commit1062d3c

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

‎coverage/control.py‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -678,15 +678,12 @@ def combine(self, data_paths=None, strict=False):
678678
self._post_init()
679679
self.get_data()
680680

681-
aliases=None
682-
ifself.config.paths:
683-
aliases=PathAliases()
684-
forpathsinself.config.paths.values():
685-
result=paths[0]
686-
forpatterninpaths[1:]:
687-
aliases.add(pattern,result)
688-
689-
combine_parallel_data(self._data,aliases=aliases,data_paths=data_paths,strict=strict)
681+
combine_parallel_data(
682+
self._data,
683+
aliases=PathAliases.configure(self.config),
684+
data_paths=data_paths,
685+
strict=strict,
686+
)
690687

691688
defget_data(self):
692689
"""Get the collected data.

‎coverage/files.py‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ class TreeMatcher(object):
215215
somewhere in a subtree rooted at one of the directories.
216216
217217
"""
218-
def__init__(self,paths):
218+
def__init__(self,paths,aliases=None):
219+
self.aliases=aliases
219220
self.paths=list(paths)
220221

221222
def__repr__(self):
@@ -227,6 +228,9 @@ def info(self):
227228

228229
defmatch(self,fpath):
229230
"""Does `fpath` indicate a file in one of our trees?"""
231+
ifself.aliasesisnotNone:
232+
fpath=self.aliases.map(fpath)
233+
230234
forpinself.paths:
231235
iffpath.startswith(p):
232236
iffpath==p:
@@ -268,7 +272,8 @@ def match(self, module_name):
268272

269273
classFnmatchMatcher(object):
270274
"""A matcher for files by file name pattern."""
271-
def__init__(self,pats):
275+
def__init__(self,pats,aliases=None):
276+
self.aliases=aliases
272277
self.pats=list(pats)
273278
self.re=fnmatches_to_regex(self.pats,case_insensitive=env.WINDOWS)
274279

@@ -281,6 +286,8 @@ def info(self):
281286

282287
defmatch(self,fpath):
283288
"""Does `fpath` match one of our file name patterns?"""
289+
ifself.aliasesisnotNone:
290+
fpath=self.aliases.map(fpath)
284291
returnself.re.match(fpath)isnotNone
285292

286293

@@ -408,6 +415,21 @@ def map(self, path):
408415
returnpath
409416

410417

418+
@classmethod
419+
defconfigure(cls,config):
420+
paths=config.paths
421+
ifnotpaths:
422+
returnNone
423+
424+
aliases=PathAliases()
425+
forpathsinpaths.values():
426+
result=paths[0]
427+
forpatterninpaths[1:]:
428+
aliases.add(pattern,result)
429+
returnaliases
430+
431+
432+
411433
deffind_python_files(dirname):
412434
"""Yield all of the importable Python files in `dirname`, recursively.
413435

‎coverage/inorout.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
fromcoverage.backwardimportcode_object
1818
fromcoverage.dispositionimportFileDisposition,disposition_init
1919
fromcoverage.filesimportTreeMatcher,FnmatchMatcher,ModuleMatcher
20-
fromcoverage.filesimportprep_patterns,find_python_files,canonical_filename
20+
fromcoverage.filesimportprep_patterns,find_python_files,canonical_filename,PathAliases
2121
fromcoverage.miscimportCoverageException
2222
fromcoverage.pythonimportsource_for_file,source_for_morf
2323

@@ -132,6 +132,7 @@ def __init__(self, warn, debug):
132132

133133
defconfigure(self,config):
134134
"""Apply the configuration to get ready for decision-time."""
135+
aliases=PathAliases.configure(config)
135136
forsrcinconfig.sourceor []:
136137
ifos.path.isdir(src):
137138
self.source.append(canonical_filename(src))
@@ -186,24 +187,24 @@ def debug(msg):
186187
ifself.sourceorself.source_pkgs:
187188
against= []
188189
ifself.source:
189-
self.source_match=TreeMatcher(self.source)
190+
self.source_match=TreeMatcher(self.source,aliases=aliases)
190191
against.append("trees {!r}".format(self.source_match))
191192
ifself.source_pkgs:
192193
self.source_pkgs_match=ModuleMatcher(self.source_pkgs)
193194
against.append("modules {!r}".format(self.source_pkgs_match))
194195
debug("Source matching against "+" and ".join(against))
195196
else:
196197
ifself.cover_paths:
197-
self.cover_match=TreeMatcher(self.cover_paths)
198+
self.cover_match=TreeMatcher(self.cover_paths,aliases=aliases)
198199
debug("Coverage code matching: {!r}".format(self.cover_match))
199200
ifself.pylib_paths:
200-
self.pylib_match=TreeMatcher(self.pylib_paths)
201+
self.pylib_match=TreeMatcher(self.pylib_paths,aliases=aliases)
201202
debug("Python stdlib matching: {!r}".format(self.pylib_match))
202203
ifself.include:
203-
self.include_match=FnmatchMatcher(self.include)
204+
self.include_match=FnmatchMatcher(self.include,aliases=aliases)
204205
debug("Include matching: {!r}".format(self.include_match))
205206
ifself.omit:
206-
self.omit_match=FnmatchMatcher(self.omit)
207+
self.omit_match=FnmatchMatcher(self.omit,aliases=aliases)
207208
debug("Omit matching: {!r}".format(self.omit_match))
208209

209210
defshould_trace(self,filename,frame=None):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp