roma-glushko / notifykit

👀 A performant, cross-platform, modern Pythonic toolkit for building applications that need watching filesystem events
https://notifykit.readthedocs.io/en/latest/
Apache License 2.0
7 stars 1 forks source link
asyncio cross-platform filesystem fsevents inotify linux macos python python3

notifykit

👀 A cross-platform filesystem watcher toolkit for Python

notifykit is a set of components for building modern Python applications with a need for watching filesystem events efficiently.

[!Warning] notifykit is under active development right now

Installation

pip install notifykit
# or
poetry add notifykit
# or 
pdm add notifykit

notifykit is available for:

CPython 3.8-3.12 on the following platforms:

PyPY 3.8-3.10 on the following platforms:

Usage

import asyncio
import os
from pathlib import Path

from notifykit import Notifier

async def watch(watched_dir: Path) -> None:
    notifier = Notifier(debounce_ms=200, debug=True)
    notifier.watch([watched_dir])

    async for event in notifier:
        # process your events
        print(event)

if __name__ == "__main__":
    watched_dir = Path("./watched_dir")
    os.makedirs(watched_dir, exist_ok=True)

    asyncio.run(watch(watched_dir))

Features

Sources of Inspiration