refactored monitor handler interaction to better allow differing event types in same system

This commit is contained in:
PatchOfScotland
2023-01-13 18:04:50 +01:00
parent e9519d718f
commit d9004394c1
11 changed files with 357 additions and 355 deletions

View File

@ -3,7 +3,7 @@ from inspect import signature
from os.path import sep, exists, isfile, isdir, dirname
from typing import Any, _SpecialForm, Union, Tuple, get_origin, get_args
from core.correctness.vars import VALID_PATH_CHARS, get_not_imp_msg
from core.correctness.vars import VALID_PATH_CHARS, get_not_imp_msg, EVENT_TYPE
def check_type(variable:Any, expected_type:type, alt_types:list[type]=[],
or_none:bool=False)->None:
@ -178,3 +178,8 @@ def setup_debugging(print:Any=None, logging:int=0)->Tuple[Any,int]:
"'write' function")
return print, logging
def valid_event(event)->None:
check_type(event, dict)
if not EVENT_TYPE in event.keys():
raise KeyError(f"Events require key '{EVENT_TYPE}'")

View File

@ -187,7 +187,14 @@ APPENDING_NOTEBOOK = {
"nbformat_minor": 4
}
# events
# meow events
EVENT_TYPE = "meow_event_type"
WATCHDOG_TYPE = "watchdog"
WATCHDOG_SRC = "src_path"
WATCHDOG_BASE = "monitor_base"
WATCHDOG_RULE = "rule_name"
# inotify events
FILE_CREATE_EVENT = "file_created"
FILE_MODIFY_EVENT = "file_modified"
FILE_MOVED_EVENT = "file_moved"