diff --git a/cctv-scheduler.py b/cctv-scheduler.py index 722c2d2..f22d7dd 100644 --- a/cctv-scheduler.py +++ b/cctv-scheduler.py @@ -1524,6 +1524,37 @@ class FFmpeg: return None +class Do(): + """Set of various methods (functions) for routine. + """ + @staticmethod + def args_valid(arguments: dict, annotations: dict) -> bool: + """Arguments type validating by annotations. + + Args: + arguments (dict): 'locals()' immediately after starting the function. + annotations (dict): function.name.__annotations__. + + Raises: + TypeError: type of argument is not equal type in annotation. + + Returns: + bool: True if argument types are valid. + """ + for var_name, var_type in annotations.items(): + if not var_name == 'return': + if not isinstance(arguments[var_name], var_type): + raise TypeError("" + + "type of '" + + var_name + + "' = " + + str(arguments[var_name]) + + " is not " + + str(var_type) + ) + return True + + if __name__ == "__main__": time_start = datetime.now()