grigori package

Submodules

grigori.watcher module

class grigori.watcher.Change[source]

Bases: enum.IntEnum

Simple Enum representing the different types of changes to a file.

ADDED = 1
DELETED = 3
MODIFIED = 2
class grigori.watcher.Watcher(directory: str, recursive: bool = False, polling_interval: int = 1000, file_pattern: str = '.+', directory_pattern: str = '.+', cache: bool = False)[source]

Bases: object

Class that starts watching your files.

on(change_type: grigori.watcher.Change, callback: function) → None[source]

Register a callback function for a type of change.

Parameters:
  • change_type – The type of the change.
  • callback – A function to call when a change of the given type occurs.
wait() → None[source]

Hacky method to use the ‘watch’ method without a ‘for loop’.

watch() → generator[source]

Keep polling for file changes and yield them.

Returns:A generator that yields a list of changes.

Module contents

Basic watcher module.

The grigori module contains two classes:

  • grigori.Change
  • grigori.Watcher

You can use the grigori.Watcher class to create a watcher instance. Then you have the choice if you want to use callbacks or a for loop. To use callbacks, use the grigori.Watcher.wait() method. To use the for loop, use the grigori.Watcher.watch() method.