Implements the interface of ``py.path.local.visit()`` for Path objects, to simplify porting the code over from ``py.path.local``.
(
path: Path, *, filter: Callable[[Path], bool], recurse: Callable[[Path], bool]
)
| 6 | |
| 7 | |
| 8 | def visit_path( |
| 9 | path: Path, *, filter: Callable[[Path], bool], recurse: Callable[[Path], bool] |
| 10 | ) -> Iterator[Path]: |
| 11 | """ |
| 12 | Implements the interface of ``py.path.local.visit()`` for Path objects, |
| 13 | to simplify porting the code over from ``py.path.local``. |
| 14 | """ |
| 15 | for dirpath, dirnames, filenames in os.walk(path): |
| 16 | dirnames[:] = [x for x in dirnames if recurse(Path(dirpath, x))] |
| 17 | for name in chain(dirnames, filenames): |
| 18 | p = Path(dirpath, name) |
| 19 | if filter(p): |
| 20 | yield p |
no outgoing calls
searching dependent graphs…