def _load_modules(self, conf: WhatTheFileConfiguration) -> None: module_index = 0 for module_section_name in conf.get_modules_section_names(): try: active = conf.get_property_boolean(module_section_name, "active") except: active = False if active: Log.info("Loading module: [" + module_section_name + "]") mod = self._import_module(conf, module_section_name, module_index) if mod is not None: module_index += 1 self.__modules.append(mod) Log.info("Module loaded successfully: [" + str(mod.get_index()) + "] - " + mod.get_name()) else: Log.error("Error loading module: [" + module_section_name + "]")
def test_load_conf_dict(self): conf = WhatTheFileConfiguration() conf.parse_dict(self.get_conf_dict()) self.assertEqual(len(conf.get_modules_names()), 10) self.assertTrue(conf.get_property_boolean("module.hashes", "active")) self.assertTrue("active" in conf.get_section("module.hashes"))
def test_load_conf_file(self): conf = WhatTheFileConfiguration() conf.parse_file('./tests/examples/whatthefile.ini') self.assertEqual(len(conf.get_modules_names()), 10) self.assertTrue(conf.get_property_boolean("module.hashes", "active")) self.assertTrue("active" in conf.get_section("module.hashes"))