Skip to content

Commit 0265b57

Browse files
committed
Rewrite include finction to only heed nearest library
1 parent 92475ae commit 0265b57

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

tools/resources/__init__.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,19 @@ def add_file_ref(self, file_type, file_name, file_path):
268268

269269
def _include_file(self, ref):
270270
_, path = ref
271-
starts_with_included = any(
272-
path.startswith(dirname(e.path))
273-
for e in self._libs_filtered
274-
)
275-
starts_with_excluded = any(
276-
path.startswith(dirname(e.path))
277-
for e in self._excluded_libs
278-
)
279-
return starts_with_included or not starts_with_excluded
271+
starts_with_excluded = [
272+
len(dirname(e.path)) for e in self._excluded_libs
273+
if path.startswith(dirname(e.path))
274+
]
275+
if not starts_with_excluded:
276+
return True
277+
starts_with_included = [
278+
len(dirname(e.path)) for e in self._libs_filtered
279+
if path.startswith(dirname(e.path))
280+
]
281+
if not starts_with_included:
282+
return False
283+
return max(starts_with_included) > max(starts_with_excluded)
280284

281285
def get_file_refs(self, file_type):
282286
"""Return a list of FileRef for every file of the given type"""

0 commit comments

Comments
 (0)