Cross-platform file system watcher for real-time monitoring
Project description
libfilewatcher
Cross-platform file system watcher for real-time monitoring
Install
pip install libfilewatcher
Usage
from libfilewatcher import FileWatcher, FileWatcherEvent
watcher = FileWatcher(root_dir="/path/to/watch")
def on_file_change(event: FileWatcherEvent):
print(f"File {event.event_type}: {event.file}")
watcher.add_callback(on_file_change)
watcher.start()
# Or use async
import asyncio
event = await watcher.get_event(timeout=5.0)
API
FileWatcherEvent
Dataclass representing a file system event.
file: str— Absolute path to the fileevent_type: str— One of "add", "change", "unlink"
FileWatcher
Main class for watching file system changes.
FileWatcher(
root_dir: str | None = None,
ignore_patterns: list[str] | None = None,
enabled: bool = True,
)
Methods:
start()— Start watchingstop()— Stop watchingadd_callback(callback)— Add event callbackremove_callback(callback)— Remove callbackasync get_event(timeout)— Get next eventis_running— Property checking if watcher is active
FileWatcherManager
Manage multiple watchers.
manager = FileWatcherManager()
watcher = manager.create_watcher("name", root_dir="...")
manager.start_all()
manager.stop_all()
CLI
# Watch current directory
libfilewatcher watch
# Watch specific directory
libfilewatcher watch /path/to/directory
# Watch with ignore patterns
libfilewatcher watch /path/to/directory --ignore "*.log" --ignore "*.tmp"
Development
git clone https://github.com/daedalus/libfilewatcher.git
cd libfilewatcher
pip install -e ".[test]"
# run tests
pytest
# format
ruff format src/ tests/
# lint
ruff check src/ tests/
# type check
mypy src/
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
libfilewatcher-0.1.0.tar.gz
(6.6 kB
view details)
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 libfilewatcher-0.1.0.tar.gz.
File metadata
- Download URL: libfilewatcher-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fdb24296afa07726dc7e97f82e1c1a5aaf59431c9319c43d828787e3093c915c
|
|
| MD5 |
1b16e985f92d02d9d48cc4d518a0b6a5
|
|
| BLAKE2b-256 |
fc2830dda2a0db77b43a1a7b25c4755434555d56d9be263359b7ccb17432ba94
|
File details
Details for the file libfilewatcher-0.1.0-py3-none-any.whl.
File metadata
- Download URL: libfilewatcher-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7679dd6182e105b7b13a5ad3dddee3a36717b5d60a614800ec1e31e65501510a
|
|
| MD5 |
f7be9bf2672b4ed45b11b03358379379
|
|
| BLAKE2b-256 |
40bf69512ec5a13e6bb62d51ac8f7a6fa7eacc1e32e35d3035db55cc78c9294e
|