Watches a directory for file changes.
Project description
# Grigori
Grigori is a small Python 3 module that watches over your files and notifies you of changes.
## Usage
There are currently 2 ways you can use Grigori, with a for loop, or with callbacks.
**For loops**
For the complete example, see `/examples/basic.py`.
```python
w = Watcher(directory)
for changes in w.watch():
for change in changes:
print("file '%s' has been changed in the following way: '%s'" % (change["file"], change["type"]))
```
**Callbacks**
For the complete example, see `/examples/callbacks.py`.
```python
w = Watcher("./directory/to/watch")
# Bind the callbacks.
w.on(Change.ADDED, on_added)
w.on(Change.MODIFIED, on_modified)
w.on(Change.DELETED, on_deleted)
w.wait() # Start watching the files.
```
## To Do
Allow for watching multiple top-level directories, which will be each watched in threads using a thread pool.
Add `inotify` support.
Add Handler classes that can be used instead of for loops or callbacks.
Grigori is a small Python 3 module that watches over your files and notifies you of changes.
## Usage
There are currently 2 ways you can use Grigori, with a for loop, or with callbacks.
**For loops**
For the complete example, see `/examples/basic.py`.
```python
w = Watcher(directory)
for changes in w.watch():
for change in changes:
print("file '%s' has been changed in the following way: '%s'" % (change["file"], change["type"]))
```
**Callbacks**
For the complete example, see `/examples/callbacks.py`.
```python
w = Watcher("./directory/to/watch")
# Bind the callbacks.
w.on(Change.ADDED, on_added)
w.on(Change.MODIFIED, on_modified)
w.on(Change.DELETED, on_deleted)
w.wait() # Start watching the files.
```
## To Do
Allow for watching multiple top-level directories, which will be each watched in threads using a thread pool.
Add `inotify` support.
Add Handler classes that can be used instead of for loops or callbacks.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Grigori-1.0.1.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file Grigori-1.0.1.tar.gz
.
File metadata
- Download URL: Grigori-1.0.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c908698de0f0f3bae439850f2a334a775fbfa5f67aebb8a7f004eac189da070 |
|
MD5 | 191f72b3edf3dc099ba0428968cd5691 |
|
BLAKE2b-256 | 33a248b03e0cb1e41d08e2c0cd819454340c81fab87ba1b14e1340efc32c1104 |
File details
Details for the file Grigori-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: Grigori-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bce56bfc82a6c4234ec4db48da5d4dfdde7f10efd05a2a632558072a5f2c50c1 |
|
MD5 | e098c692852d953ccff7386757aecc42 |
|
BLAKE2b-256 | d6068f44218fa7e050355c53b7bdade7024e23c9bd0657ae7fb3397707a9beb9 |