added a few more comments

This commit is contained in:
PatchOfScotland
2023-02-03 16:29:49 +01:00
parent d823b50fc9
commit d787e37adc

View File

@ -289,6 +289,8 @@ def parameterize_python_script(script:list[str], parameters:dict[str,Any],
return output_script return output_script
def print_debug(print_target, debug_level, msg, level)->None: def print_debug(print_target, debug_level, msg, level)->None:
"""Function to print a message to the debug target, if its level exceeds
the given one."""
if print_target is None: if print_target is None:
return return
else: else:
@ -302,6 +304,8 @@ def print_debug(print_target, debug_level, msg, level)->None:
def replace_keywords(old_dict:dict[str,str], job_id:str, src_path:str, def replace_keywords(old_dict:dict[str,str], job_id:str, src_path:str,
monitor_base:str)->dict[str,str]: monitor_base:str)->dict[str,str]:
"""Function to replace all MEOW magic words in a dictionary with dynamic
values."""
new_dict = {} new_dict = {}
filename = os.path.basename(src_path) filename = os.path.basename(src_path)
@ -330,6 +334,7 @@ def replace_keywords(old_dict:dict[str,str], job_id:str, src_path:str,
def create_event(event_type:str, path:str, rule:Any, extras:dict[Any,Any]={} def create_event(event_type:str, path:str, rule:Any, extras:dict[Any,Any]={}
)->dict[Any,Any]: )->dict[Any,Any]:
"""Function to create a MEOW dictionary."""
return { return {
**extras, **extras,
EVENT_PATH: path, EVENT_PATH: path,
@ -339,6 +344,7 @@ def create_event(event_type:str, path:str, rule:Any, extras:dict[Any,Any]={}
def create_watchdog_event(path:str, rule:Any, base:str, hash:str, def create_watchdog_event(path:str, rule:Any, base:str, hash:str,
extras:dict[Any,Any]={})->dict[Any,Any]: extras:dict[Any,Any]={})->dict[Any,Any]:
"""Function to create a MEOW event dictionary."""
return create_event( return create_event(
EVENT_TYPE_WATCHDOG, EVENT_TYPE_WATCHDOG,
path, path,
@ -354,6 +360,7 @@ def create_watchdog_event(path:str, rule:Any, base:str, hash:str,
def create_job(job_type:str, event:dict[str,Any], extras:dict[Any,Any]={} def create_job(job_type:str, event:dict[str,Any], extras:dict[Any,Any]={}
)->dict[Any,Any]: )->dict[Any,Any]:
"""Function to create a MEOW job dictionary."""
job_dict = { job_dict = {
#TODO compress event? #TODO compress event?
JOB_ID: generate_id(prefix="job_"), JOB_ID: generate_id(prefix="job_"),
@ -370,4 +377,6 @@ def create_job(job_type:str, event:dict[str,Any], extras:dict[Any,Any]={}
return {**extras, **job_dict} return {**extras, **job_dict}
def lines_to_string(lines:list[str])->str: def lines_to_string(lines:list[str])->str:
"""Function to convert a list of str lines, into one continuous string
separated by newline characters"""
return "\n".join(lines) return "\n".join(lines)