walk_folder_paths¶
- pathwalker.walk_folder_paths(root_path: Union[str, pathlib.Path], filter_pattern: Optional[str] = None, recursive: bool = False) Iterator[pathlib.Path] ¶
Yields only paths of directories.
- Parameters
root_path (Path) – Root path to walk thourgh.
filter_pattern (str) – Unix path pattern for filtering retrieved paths.
recursive(bool – Returns also paths of all sub folders.
- Yields
Path
Examples
>>> from doctestprinter import doctest_iter_print >>> from pathwalker import walk_folder_paths >>> found_folders = sorted( ... walk_folder_paths("./tests", filter_pattern = "[!._]*"), ... key=lambda x: str(x) ... ) >>> doctest_iter_print(found_folders) tests/resources
>>> found_folders = sorted( ... walk_folder_paths("./tests", filter_pattern = "[!._]*", recursive=True), ... key=lambda x: str(x) ... ) >>> doctest_iter_print(found_folders) tests/resources tests/resources/another_bar tests/resources/bar tests/resources/foo tests/resources/foo/bar