Skip to main content

Filesystem event watcher with decorator-based callbacks

Project description

philiprehberger-file-watcher

Tests PyPI version License

Filesystem event watcher with decorator-based callbacks.

Install

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

Development

pip install -e .
python -m pytest tests/ -v

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

philiprehberger_file_watcher-0.1.5.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

philiprehberger_file_watcher-0.1.5-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_file_watcher-0.1.5.tar.gz.

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.5.tar.gz
Algorithm Hash digest
SHA256 6f5d0b0ed3961b9ad9b95db12a46ede99894205cfaf82e92ca519a31ab579ed8
MD5 91a038160e867078611ac483d640256c
BLAKE2b-256 58c9d2a2d6aca0db30d09298a9c2a8e2632f750dcd6599fa13d3245c49cb3586

See more details on using hashes here.

File details

Details for the file philiprehberger_file_watcher-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5af03c94358e5a7cb12a0ae2abae7ae66e7aa42c5e4a5cc8172106516db9f666
MD5 91bcef8c3d1c7a7eed5979d2784420dc
BLAKE2b-256 23c82a77cedd56957add7730b71241743f75d7fc6524db6cd6b6782e24934a89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page