Skip to content

Commit 250a1de

Browse files
committed
Handle recursive lib exclude/includes
1 parent eb6a972 commit 250a1de

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tools/resources/__init__.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,27 @@ def add_file_ref(self, file_type, file_name, file_path):
258258
file_name = file_name.replace(sep, self._sep)
259259
self._file_refs[file_type].add(FileRef(file_name, file_path))
260260

261+
def _include_file(self, ref):
262+
_, path = ref
263+
starts_with_included = any(
264+
path.startswith(dirname(e.path))
265+
for e in self._libs_filtered
266+
)
267+
starts_with_excluded = any(
268+
path.startswith(dirname(e.path))
269+
for e in self._excluded_libs
270+
)
271+
return starts_with_included or not starts_with_excluded
272+
261273
def get_file_refs(self, file_type):
262274
"""Return a list of FileRef for every file of the given type"""
263275
if self._libs_filtered is None:
264276
return list(self._file_refs[file_type])
265277
else:
266-
to_ret = []
267-
for ref in self._file_refs[file_type]:
268-
_, path = ref
269-
if not any(
270-
path.startswith(dirname(e.path)) for e in self._excluded_libs
271-
):
272-
to_ret.append(ref)
273-
return to_ret
278+
return [
279+
ref for ref in self._file_refs[file_type]
280+
if self._include_file(ref)
281+
]
274282

275283
def filter_by_libraries(self, library_refs):
276284
"""

0 commit comments

Comments
 (0)