mosey.Walker
¶
Bases: Protocol
A directory walker, built by Mosey.build.
Walker is the type to annotate walkers with: you never create one yourself.
A walker never changes once it's built, so one walker can take any number of walks,
one after another or at the same time, on any number of threads. Each call to
walk returns its own iterator: share the walker between
threads, but never an iterator.
walk
¶
Walk a directory and yield a Step for every file not ignored.
Files are yielded in a deterministic walk order, documented at https://cariad.github.io/mosey/walk-order/.
The files and directories that the walker's patterns ignore aren't yielded or walked, nor are the files and directories within them.
Its patterns are the ones added by
Mosey.add_pattern, and, when it has an ignore-file
name (set by Mosey.set_ignore_filename),
those in each directory's ignore-file, which is read when the
walk reaches the directory.
A relative root is found from the working directory each time a subdirectory is read, so don't change the working directory during a walk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
PathLike[str] | str
|
Path to the directory to walk. |
required |
Returns:
| Type | Description |
|---|---|
Iterator[Step]
|
An iterator of The iterator raises When the walker has an ignore-file name, it also raises
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
When |
NotADirectoryError
|
When |
OSError
|
When the operating system can't resolve |
PermissionError
|
When file system permissions deny reaching or listing
|
ValueError
|
When |