Filesystem event watcher with decorator-based callbacks
Project description
philiprehberger-file-watcher
Filesystem event watcher with decorator-based callbacks.
Installation
pip install philiprehberger-file-watcher
Usage
from philiprehberger_file_watcher import Watcher
watcher = Watcher("./src")
@watcher.on("created", pattern="*.py")
def on_new_python_file(event):
print(f"New file: {event.path}")
@watcher.on("modified", pattern="*.css")
def on_css_change(event):
print(f"CSS changed: {event.path}")
@watcher.on("any")
def on_anything(event):
print(f"{event.type}: {event.path}")
# Blocking
watcher.start()
# Or background mode
watcher.start(background=True)
# ... do other work ...
watcher.stop()
Event Types
"created", "modified", "deleted", "moved", "any"
Options
| Option | Default | Description |
|---|---|---|
recursive |
True | Watch subdirectories |
debounce |
0.5 | Debounce interval in seconds |
API
| Function / Class | Description |
|---|---|
Watcher(path, recursive, debounce) |
Watch a directory for filesystem changes with decorator-based event handlers |
FileEvent |
A filesystem event with type, path, is_directory, and dest_path fields |
Development
pip install -e .
python -m pytest tests/ -v
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file philiprehberger_file_watcher-0.1.8.tar.gz.
File metadata
- Download URL: philiprehberger_file_watcher-0.1.8.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94be6c08d1eebd72a362a5076aaa1911bdde199b11f132c4a0cbdba1953197c4
|
|
| MD5 |
80cea19b8e8ff8c8b8b67cf6f5af5734
|
|
| BLAKE2b-256 |
488f8b81e0e611166f4d3333967784b4905fd9672f348867a911bad2739a73f8
|
File details
Details for the file philiprehberger_file_watcher-0.1.8-py3-none-any.whl.
File metadata
- Download URL: philiprehberger_file_watcher-0.1.8-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cee4c4a506692ecd5bc3745ea9e6a546780bf792ce7f9744fa9e7a78e7da648
|
|
| MD5 |
fd78bd0c8f56e16838f1caee3864157d
|
|
| BLAKE2b-256 |
9b1d400ae6ba7a23a087665886442438f24371d50e2eef8c7fdeebf27d68ed9b
|