Functions
_should_watch
2
bool
▼
Check if a path should be watched for changes.
_should_watch
2
bool
▼
def _should_watch(path: Path, extensions: frozenset[str] = _WATCH_EXTENSIONS) -> bool
Parameters
| Name | Type | Description |
|---|---|---|
path |
Path |
|
extensions |
frozenset[str] |
Default:_WATCH_EXTENSIONS
|
Returns
bool
_snapshot
2
dict[str, float]
▼
Take a snapshot of file modification times.
_snapshot
2
dict[str, float]
▼
def _snapshot(directories: list[Path], extensions: frozenset[str] = _WATCH_EXTENSIONS) -> dict[str, float]
Parameters
| Name | Type | Description |
|---|---|---|
directories |
list[Path] |
|
extensions |
frozenset[str] |
Default:_WATCH_EXTENSIONS
|
Returns
dict[str, float]
detect_changes
3
tuple[set[str], dict[str…
▼
Compare current state against a previous snapshot.
detect_changes
3
tuple[set[str], dict[str…
▼
def detect_changes(directories: list[Path], previous: dict[str, float], extensions: frozenset[str] = _WATCH_EXTENSIONS) -> tuple[set[str], dict[str, float]]
Parameters
| Name | Type | Description |
|---|---|---|
directories |
list[Path] |
Directories to scan. |
previous |
dict[str, float] |
Previous snapshot from |
extensions |
frozenset[str] |
File extensions to watch. Default:_WATCH_EXTENSIONS
|
Returns
tuple[set[str], dict[str, float]]
watch_for_changes
5
None
▼
Poll directories for changes and call callback on detection.
This is a blockin…
watch_for_changes
5
None
▼
def watch_for_changes(directories: list[Path], callback: Callable[[], None], *, interval: float = 1.0, stop_event: threading.Event | None = None, extra_extensions: tuple[str, ...] = ()) -> None
Poll directories for changes and call callback on detection.
This is a blocking function designed to run in a thread. It polls
at the given interval and callscallback()whenever changes
are detected.
Parameters
| Name | Type | Description |
|---|---|---|
directories |
list[Path] |
Directories to watch. |
callback |
Callable[[], None] |
Called (with no args) when changes are detected. |
interval |
float |
Polling interval in seconds (default: 1.0). Default:1.0
|
stop_event |
threading.Event | None |
Optional threading.Event to stop the watcher. Default:None
|
extra_extensions |
tuple[str, ...] |
Additional file extensions to watch beyond the built-in set (e.g. ()
|