Metadata-Version: 2.4
Name: philiprehberger-file-watcher
Version: 0.1.7
Summary: Filesystem event watcher with decorator-based callbacks
Project-URL: Homepage, https://github.com/philiprehberger/py-file-watcher#readme
Project-URL: Repository, https://github.com/philiprehberger/py-file-watcher
Project-URL: Issues, https://github.com/philiprehberger/py-file-watcher/issues
Project-URL: Changelog, https://github.com/philiprehberger/py-file-watcher/blob/main/CHANGELOG.md
Author: Philip Rehberger
License-Expression: MIT
License-File: LICENSE
Keywords: events,file-watcher,filesystem,monitor,watch
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: watchdog>=3.0
Description-Content-Type: text/markdown

# philiprehberger-file-watcher

[![Tests](https://github.com/philiprehberger/py-file-watcher/actions/workflows/publish.yml/badge.svg)](https://github.com/philiprehberger/py-file-watcher/actions/workflows/publish.yml)
[![PyPI version](https://img.shields.io/pypi/v/philiprehberger-file-watcher.svg)](https://pypi.org/project/philiprehberger-file-watcher/)
[![License](https://img.shields.io/github/license/philiprehberger/py-file-watcher)](LICENSE)

Filesystem event watcher with decorator-based callbacks.

## Installation

```bash
pip install philiprehberger-file-watcher
```

## Usage

```python
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

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

## License

MIT
