Metadata-Version: 2.4
Name: libfilewatcher
Version: 0.1.0
Summary: Cross-platform file system watcher for real-time monitoring
Project-URL: Homepage, https://github.com/daedalus/libfilewatcher
Project-URL: Repository, https://github.com/daedalus/libfilewatcher
Project-URL: Issues, https://github.com/daedalus/libfilewatcher/issues
Author-email: Dario Clavijo <clavijodario@gmail.com>
License: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: watchdog
Provides-Extra: all
Requires-Dist: hatch; extra == 'all'
Requires-Dist: hypothesis; extra == 'all'
Requires-Dist: mypy; extra == 'all'
Requires-Dist: pip-api; extra == 'all'
Requires-Dist: pytest; extra == 'all'
Requires-Dist: pytest-asyncio; extra == 'all'
Requires-Dist: pytest-cov; extra == 'all'
Requires-Dist: pytest-mock; extra == 'all'
Requires-Dist: ruff; extra == 'all'
Provides-Extra: dev
Requires-Dist: hatch; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pip-api; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Provides-Extra: lint
Requires-Dist: mypy; extra == 'lint'
Requires-Dist: ruff; extra == 'lint'
Provides-Extra: test
Requires-Dist: hypothesis; extra == 'test'
Requires-Dist: pytest; extra == 'test'
Requires-Dist: pytest-asyncio; extra == 'test'
Requires-Dist: pytest-cov; extra == 'test'
Requires-Dist: pytest-mock; extra == 'test'
Description-Content-Type: text/markdown

# libfilewatcher

> Cross-platform file system watcher for real-time monitoring

[![PyPI](https://img.shields.io/pypi/v/libfilewatcher.svg)](https://pypi.org/project/libfilewatcher/)
[![Python](https://img.shields.io/pypi/pyversions/libfilewatcher.svg)](https://pypi.org/project/libfilewatcher/)
[![Coverage](https://codecov.io/gh/daedalus/libfilewatcher/branch/main/graph/badge.svg)](https://codecov.io/gh/daedalus/libfilewatcher)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

## Install

```bash
pip install libfilewatcher
```

## Usage

```python
from libfilewatcher import FileWatcher, FileWatcherEvent

watcher = FileWatcher(root_dir="/path/to/watch")

def on_file_change(event: FileWatcherEvent):
    print(f"File {event.event_type}: {event.file}")

watcher.add_callback(on_file_change)
watcher.start()

# Or use async
import asyncio
event = await watcher.get_event(timeout=5.0)
```

## API

### `FileWatcherEvent`

Dataclass representing a file system event.

- `file: str` — Absolute path to the file
- `event_type: str` — One of "add", "change", "unlink"

### `FileWatcher`

Main class for watching file system changes.

```python
FileWatcher(
    root_dir: str | None = None,
    ignore_patterns: list[str] | None = None,
    enabled: bool = True,
)
```

Methods:
- `start()` — Start watching
- `stop()` — Stop watching
- `add_callback(callback)` — Add event callback
- `remove_callback(callback)` — Remove callback
- `async get_event(timeout)` — Get next event
- `is_running` — Property checking if watcher is active

### `FileWatcherManager`

Manage multiple watchers.

```python
manager = FileWatcherManager()
watcher = manager.create_watcher("name", root_dir="...")
manager.start_all()
manager.stop_all()
```

## CLI

```bash
# Watch current directory
libfilewatcher watch

# Watch specific directory
libfilewatcher watch /path/to/directory

# Watch with ignore patterns
libfilewatcher watch /path/to/directory --ignore "*.log" --ignore "*.tmp"
```

## Development

```bash
git clone https://github.com/daedalus/libfilewatcher.git
cd libfilewatcher
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint
ruff check src/ tests/

# type check
mypy src/
```