Walk a directory recursively, in breadth-first order. The `recurse` predicate determines whether a directory is recursed. Entries at each directory level are sorted.
(
path: str | os.PathLike[str], recurse: Callable[[os.DirEntry[str]], bool]
)
| 971 | |
| 972 | |
| 973 | def visit( |
| 974 | path: str | os.PathLike[str], recurse: Callable[[os.DirEntry[str]], bool] |
| 975 | ) -> Iterator[os.DirEntry[str]]: |
| 976 | """Walk a directory recursively, in breadth-first order. |
| 977 | |
| 978 | The `recurse` predicate determines whether a directory is recursed. |
| 979 | |
| 980 | Entries at each directory level are sorted. |
| 981 | """ |
| 982 | entries = scandir(path) |
| 983 | yield from entries |
| 984 | for entry in entries: |
| 985 | if entry.is_dir() and recurse(entry): |
| 986 | yield from visit(entry.path, recurse) |
| 987 | |
| 988 | |
| 989 | def absolutepath(path: str | os.PathLike[str]) -> Path: |