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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.6.tar.gz
Algorithm Hash digest
SHA256 effb5cbf703b46f3d84886d81c3e5730d5481ed02c2f9d9c5a7665bb983d20d5
MD5 b23eaddb137f97d4800b84b9c61703ad
BLAKE2b-256 43578ccef7de0866d038d9288ca912ffe2dad6933683a4f616bc08ec3ec21a7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 19cb0267061a4386989622ec93206c57d0f66e8f347147bc939574734b4df9ce
MD5 4e67af93d32cb3174fd8bc52c63085f4
BLAKE2b-256 f9d9a99db84e589905426cb55c588251e2ac66ba5dc7c1987f120e2030945d16

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