48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
from watchdog.observers import Observer
|
|
from watchdog.events import FileSystemEventHandler
|
|
|
|
global garden
|
|
"""
|
|
Map of instances to list of signals
|
|
to be processed
|
|
"""
|
|
garden = {}
|
|
|
|
|
|
class Compound(FileSystemEventHandler):
|
|
"""
|
|
File system watcher to propagate disk changes
|
|
"""
|
|
|
|
def __init__(self, cache, isCatch: bool = False):
|
|
"""
|
|
Parameters
|
|
----------
|
|
cache: Cache
|
|
Daisy cache to update
|
|
|
|
isCatch: bool
|
|
Is the cache for catchs
|
|
"""
|
|
self.cache = cache
|
|
self.isCatch = isCatch
|
|
super().__init__()
|
|
|
|
def on_any_event(self, event):
|
|
"""
|
|
Called when a CRUD operation is performed on a record file
|
|
|
|
Parameters
|
|
----------
|
|
event
|
|
Event object provided by watchdog
|
|
"""
|
|
if not (".json" in event.src_path):
|
|
if not (".md" in event.src_path):
|
|
tpath = "/".join(event.src_path.split("/")[1:])
|
|
if tpath != "":
|
|
if self.isCatch:
|
|
self.cache.sget(tpath)
|
|
else:
|
|
self.cache.get(tpath).get()
|