A Python package for monitoring file system changes
Project description
Watcher
A Python package for monitoring file system changes.
Installation
pip install watcher-fs
Usage
from watcher_fs.watcher import Watcher, TriggerType
from pathlib import Path
test_dir = Path("test_dir")
def on_change_simple():
print(f"Something changed.")
def on_change(change):
print(f"File {change}")
watcher = Watcher()
# register as glob pattern
watcher.register("test_dir/**/*.txt", on_change_simple, TriggerType.PER_FILE)
watcher.register("test_dir/**/*.py", on_change, TriggerType.ANY_FILE, callback_extra=True)
# register as list of specified files
watcher.register([
test_dir / "skin.styl",
test_dir / "styl/default.styl",
test_dir / "styl/utils.styl"
], on_change, TriggerType.ANY_FILE, callback_extra=True)
# Simulate a check
watcher.check()
# do something
with open(test_dir / "aaa.txt", "w") as f:
f.write("Modified content")
with open(test_dir / "bbb.txt", "w") as f:
f.write("Modified content")
with open(test_dir / "skin.styl", "w") as f:
f.write("a = #0af")
with open(test_dir / "styl/default.styl", "w") as f:
f.write("a = #f00")
# check again
watcher.check()
Documentation
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 watcher_fs-1.1.0-py3-none-any.whl.
File metadata
- Download URL: watcher_fs-1.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54c514996b29b03111558d171ac948dd227922d50a95262c0e473abec811b8dd
|
|
| MD5 |
94a08d4d9d6b3be8c8f152b1a88b11c8
|
|
| BLAKE2b-256 |
579760fe6062f9399b23721df0e5f002e6dd3cfa5864da0f5005661ed0ada292
|