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.

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


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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.7.tar.gz
Algorithm Hash digest
SHA256 71e75688bc7d255e7e308f7d55b7264798657adad6bc699a24c35d598abc8a01
MD5 f8af1eafc5ace4efb8fd03aee57ee934
BLAKE2b-256 d14a57cafb3943665b16b04961cf737f752fa194e4d13aba753d0dd684a4428f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fd662decc67bad37d7ebcfe4b3ef8f101b911bcdff97ec83a40e64fe42df9b93
MD5 b9806fd8843afdf8a936d95f1d51c1aa
BLAKE2b-256 9475a494413cb289730af564d6a335ccc199f5b994f9c461d1eda6001f729090

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