Linux inotify wrapper
Project description
inotify_lite
inotify_lite is a Python 3.8 wrapper around inotify (see inotify(7)).
Usage
Classes
IN_FLAGS
class IN_FLAGS(enum.IntFlag)
Wrapper around the underlying C lib flags. See inotify_add_watch(2), <sys/inotify.h>
, <bits/inotify.h>
.
Event
namedtuple("Event", ("wd", "mask", "cookie", "len", "name"))
Maps the underlying struct inotify_event
. See inotify_add_watch(2).
Inotify
Inotify(
callback: Callable[[Sequence[Event]], Any],
*files: str,
blocking: bool = True,
flags: IN_FLAGS = 0,
)
Base class for TreeWatcher
and FileWatcher
.
TreeWatcher
TreeWatcher(
callback: Callable[[Sequence[Event]], Any],
*dirs: str,
blocking: bool = True,
all_events: bool = True,
flags: IN_FLAGS = 0,
)
Watch directories. Extends Inotify
and passes IN_FLAGS.ONLYDIR
by default (raises if any of dirs
is not a directory). The all_events
option means to watch for all filesystem events (this can be quite noisy).
FileWatcher
FileWatcher(
callback: Callable[[Sequence[Event]], Any],
*files: str,
blocking: bool = True,
all_events: bool = True,
flags: IN_FLAGS = 0,
)
Watch files.
Examples
To watch a directory:
def my_callback(events):
# Just show me the event mask.
for e in events:
print(IN_FLAGS(e.mask))
# Watch the home directory for successful writes.
watcher = TreeWatcher(my_callback, "~", all_events=False, flags=IN_FLAGS.CLOSE_WRITE)
watcher.watch()
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
File details
Details for the file inotify_lite-0.0.1.tar.gz
.
File metadata
- Download URL: inotify_lite-0.0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55dda3f6b1cd1a9ee97ba5140ae7642214003dec01fc132804fcba2eb8c1db34 |
|
MD5 | 13b12bafa7de0a2efe954f76d63deefd |
|
BLAKE2b-256 | 86b201f91f52b61b14768aa26f8382b4a4c95e5fba23f483e15c98ff14754e75 |
Provenance
File details
Details for the file inotify_lite-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: inotify_lite-0.0.1-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c9694ca286765b60135ef9889abccd8abe9a3b31f7396528ab8fbfbcd34af9c |
|
MD5 | b025d2e0a0914323ba11c9b880174299 |
|
BLAKE2b-256 | e96f00d89ca2b7b909df2a2bf258951ecd205cfff042dd679c29ecc84e970822 |