def configure(conf: WhatTheFileConfiguration): try: Time._output_format = conf.get_property("whatthefile", "output_date_format") except: pass "using default value"
def configure(conf: WhatTheFileConfiguration): try: Safe.i = 0 Safe.safe_output_path = os.path.abspath( os.path.join( conf.get_property("whatthefile", "safe_output_path"), "./" + str(Safe.i)).replace("/./", "/").replace("/../", "/")) Safe.next_rotation() except: raise BaseException("safe_output_path is required")
def _import_module(conf: WhatTheFileConfiguration, module_section_name, position: int) -> Module: module_name = module_section_name.split(".")[1] try: mod = importlib.import_module( conf.get_property("whatthefile", "modules_package") + "." + module_name + ".main") py_mod = getattr(mod, "Constructor")() configuration = conf.get_whatthefile_secction() configuration.update(conf.get_section(module_section_name)) py_mod.set_params(configuration) return Module(module_name, position, py_mod) except: traceback.print_exc() return None
def configure(conf: WhatTheFileConfiguration): output = conf.get_property("whatthefile", "log_output") switcher = { "stdout": sys.stdout, "stderr": sys.stderr, "file": conf.get_section("log_output.file")["filename"] + str("_{time}.log") if "filename" in conf.get_section("log_output.file") else sys.stderr } logger.remove() logger.add(switcher.get(output, sys.stderr), format="{time} {level} {message}", level=conf.get_section("whatthefile")["log_level"] if "log_level" in conf.get_section("whatthefile") else "DEBUG")
def reset(conf: WhatTheFileConfiguration): safe_output_path = conf.get_property("whatthefile", "safe_output_path") for element in os.listdir(safe_output_path): Safe._delete(os.path.join(safe_output_path, "./" + str(element))) Safe.configure(conf)