Linux inotify wrapper
Project description
inotify_lite
inotify_lite is a Python 3.8 wrapper around inotify (see inotify(7)).
Usage
pip install inotify_lite
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,
flags: IN_FLAGS = 0,
)
Watch directories. Extends Inotify
and passes IN_FLAGS.ONLYDIR
by default (raises if any of dirs
is not a directory).
FileWatcher
FileWatcher(
callback: Callable[[Sequence[Event]], Any],
*files: str,
blocking: 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, "~", 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
inotify_lite-0.0.3.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for inotify_lite-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 463a6d811305a7d581501d69c61089c757a69839f936799fc0f61554998de76d |
|
MD5 | 6b186b2def71dc48ee5cc8518be960a2 |
|
BLAKE2b-256 | f004531f0aa21c78039b99e2f4ee3d1e762d766ba375a995929f5b83a81866de |