No project description provided
Project description
panzi-inotify
Simple inotify bindings for Python.
I didn't like all the other available inotify bindings for one reason or anther. This one is different in these ways:
- You can import the module even if your libc doesn't support inotify. It then
will have
HAS_INOTIFYfalseand only if you try to create an instance ofInotifyyou will get an exception (OSError(ENOSYS)). - It correctly handles paths that are invalid UTF-8 by using the
'surrogateescape'escape Unicode error handling option. This makes the file paths rountrip safe. wait()andread_events()is separate. You can do your own wait/poll logic if you want.read_events()only reads the available events. If there are none at the moment it returns an empty array.- You can pass a
stopfdtoInotify(). This file descriptor will be added toepoll_wait()call inInotify.wait(). IfPOLLINsignals for thatwait()will returnFalse. This is meant for implementing a way to stop a process that waits for events without a timeout. - Translates errors in the approprioate Python exceptions from the given
errno(FileNotFoundErroretc. andOSErroras fallback).
Example
from panzi_inotify import Inotify, get_inotify_event_names
import sys
with Inotify() as inotify:
for filename in sys.argv[1:]:
inotify.add_watch(filename)
for event in inotify:
print(f'{event.full_path()}: {", ".join(get_inotify_event_names(event.mask))}')
See examples for more.
You can also run a basic command line too to listen for events on a set of paths like this:
python -m panzi_inotify [--mask=MASK] <path>...
For more on this see:
python -m panzi_inotify --help
See Also
License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file panzi_inotify-1.0.0.tar.gz.
File metadata
- Download URL: panzi_inotify-1.0.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21d06320faab949a84ed1a2592c69be92cd037c7a7ad384fb10b714c557f9fa8
|
|
| MD5 |
421e41bdab746b735d816d9176c64df5
|
|
| BLAKE2b-256 |
7ed44bb4a04b55a82e6d873609c171ccdbe84992e226e38ea1ef01a3b79363e4
|
File details
Details for the file panzi_inotify-1.0.0-py3-none-any.whl.
File metadata
- Download URL: panzi_inotify-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
765978d52314208ff96fa96302eb584670ada1425f6596f144f378fdac9abd8a
|
|
| MD5 |
6c86e89b8fc171cb0fc399d7e695637c
|
|
| BLAKE2b-256 |
c69e8ed14257a64aee9ae20fe473c20b49872b253a45b7fadd5a69e420dbe241
|