fix typos, type hinting and missed changes in ModuleManager

This commit is contained in:
jesopo 2019-12-10 05:32:55 +00:00
parent 638eee0d68
commit 58c09f7342

View file

@ -129,7 +129,7 @@ class ModuleManager(object):
def list_modules(self, whitelist: typing.List[str], def list_modules(self, whitelist: typing.List[str],
blacklist: typing.List[str]) -> typing.Dict[str, ModuleDefinition]: blacklist: typing.List[str]) -> typing.Dict[str, ModuleDefinition]:
core_modules = self._list_modules(self._core_modules) core_modules = self._list_modules(self._core_modules)
extra_modules = {} extra_modules: typing.Dict[str, ModuleDefinition] = {}
for directory in self._extra_modules: for directory in self._extra_modules:
for name, module in self._list_modules(directory).items(): for name, module in self._list_modules(directory).items():
@ -180,7 +180,7 @@ class ModuleManager(object):
return os.path.basename(path).rsplit(".py", 1)[0].lower() return os.path.basename(path).rsplit(".py", 1)[0].lower()
def _module_paths(self, name: str) -> typing.List[str]: def _module_paths(self, name: str) -> typing.List[str]:
paths = [] paths = []
for directory in self.directories: for directory in [self._core_modules]+self._extra_modules:
paths.append(os.path.join(directory, name)) paths.append(os.path.join(directory, name))
return paths return paths
def _import_name(self, name: str, context: str) -> str: def _import_name(self, name: str, context: str) -> str:
@ -289,7 +289,7 @@ class ModuleManager(object):
self.log.debug("Module '%s' loaded", [loaded_module.name]) self.log.debug("Module '%s' loaded", [loaded_module.name])
return loaded_module return loaded_module
def _dependency_sort(self, definitions: typing.Dict[str, ModuleDefinition] def _dependency_sort(self, definitions: typing.List[ModuleDefinition]
) -> typing.List[ModuleDefinition]: ) -> typing.List[ModuleDefinition]:
definitions_ordered = [] definitions_ordered = []