MCPcopy
hub / github.com/pytest-dev/pytest / visit

Function visit

src/_pytest/pathlib.py:973–986  ·  view source on GitHub ↗

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]
)

Source from the content-addressed store, hash-verified

971
972
973def 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
989def absolutepath(path: str | os.PathLike[str]) -> Path:

Callers 1

Calls 1

scandirFunction · 0.85

Tested by 1