Skip to content

Commit

Permalink
exclude_dirs fixed in walker (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
tfeldmann committed Jan 12, 2024
1 parent 0b18508 commit f9f1872
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions organize/walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ class Walker:
min_depth: int = 0
max_depth: Optional[int] = None
method: Literal["breadth", "depth"] = "breadth"
filter_dirs: Optional[Iterable[str]] = None
filter_files: Optional[Iterable[str]] = None
exclude_dirs: Iterable[str] = Field(default_factory=set)
exclude_files: Iterable[str] = Field(default_factory=set)
filter_dirs: Optional[List[str]] = None
filter_files: Optional[List[str]] = None
exclude_dirs: List[str] = Field(default_factory=set)
exclude_files: List[str] = Field(default_factory=set)

def _should_yield_file(self, entry: os.DirEntry, lvl: int):
return (
Expand Down
16 changes: 16 additions & 0 deletions tests/core/test_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path

import pytest
from conftest import make_files
from pyfakefs.fake_filesystem import FakeFilesystem

from organize.walker import Walker
Expand Down Expand Up @@ -129,3 +130,18 @@ def test_walk(fs: FakeFilesystem, method):
Path("/test/d1/d1/d2"),
]
)


def test_exclude_dirs(fs):
make_files(
{
"subA": {"file.a": "", "file.b": ""},
"subB": {
"subC": {"file.ca": "", "file.cb": ""},
"file.ba": "",
"file.bb": "",
},
},
"test",
)
assert len(list(Walker(exclude_dirs=["subC"]).files("/test"))) == 4

0 comments on commit f9f1872

Please sign in to comment.