Esempio n. 1
0
 def get_output_by_conf(conf: WhatTheFileConfiguration):
     if "output" in conf.get_whatthefile_secction():
         output = conf.get_whatthefile_secction()["output"]
         if output == "print":
             return OutputFactory._get_print_output(conf.get_section("output.print"))
         if output == "list":
             return OutputFactory._get_list_output(conf.get_section("output.list"))
         if output == "file":
             return OutputFactory._get_file_output(conf.get_section("output.file"))
         if output == "elasticsearch":
             return OutputFactory._get_elasticsearch_output(conf.get_section("output.elasticsearch"))
     return OutputFactory._get_print_output(conf.get_section("output.print"))
Esempio n. 2
0
 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