Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve exclude path filesystem logic #13894

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,19 @@ def yield_blobs(

def _yield_paths(self) -> Iterable[Path]:
"""Yield paths that match the requested pattern."""

def match_exclude(path: Path) -> bool:
"""Check if the path matches any of the exclude patterns."""
for exclude_pattern in self.exclude:
for part in path.parents:
if part.match(exclude_pattern):
return True
return False

paths = self.path.glob(self.glob)
for path in paths:
if self.exclude:
if any(path.match(glob) for glob in self.exclude):
continue
if self.exclude and match_exclude(path):
continue
if path.is_file():
if self.suffixes and path.suffix not in self.suffixes:
continue
Expand Down
Loading