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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.8.tar.gz
Algorithm Hash digest
SHA256 94be6c08d1eebd72a362a5076aaa1911bdde199b11f132c4a0cbdba1953197c4
MD5 80cea19b8e8ff8c8b8b67cf6f5af5734
BLAKE2b-256 488f8b81e0e611166f4d3333967784b4905fd9672f348867a911bad2739a73f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_file_watcher-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9cee4c4a506692ecd5bc3745ea9e6a546780bf792ce7f9744fa9e7a78e7da648
MD5 fd78bd0c8f56e16838f1caee3864157d
BLAKE2b-256 9b1d400ae6ba7a23a087665886442438f24371d50e2eef8c7fdeebf27d68ed9b

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