Skip to content

Commit

Permalink
Improve exclude path filesystem logic
Browse files Browse the repository at this point in the history
  • Loading branch information
johnlarkin1 committed Nov 27, 2023
1 parent f2af820 commit 40e4a12
Showing 1 changed file with 11 additions and 3 deletions.
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

0 comments on commit 40e4a12

Please sign in to comment.