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.4.tar.gz (3.6 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.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c69e5be00a809755f85cb84e930d649659c3181bba77a511b4acdcb8a8f7583e
MD5 f5b8fe93741df64d33dc073457500920
BLAKE2b-256 8de4fe41d21042e6caffdaf07b8927f1c70494fa7ec61fafa466186eea98e0d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d6d975e796f7e0b58a690ded42796346edfd1746048d642d8ac88993fc71822c
MD5 41e337d4dc33c4660facf1483ae905bc
BLAKE2b-256 160753849e0e1c828522308a4d36bdc44f094faa4bae2b650aecfa394d0b3241

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