Added support for dynamic loaded modules

This commit is contained in:
2021-11-15 21:23:06 +01:00
parent a3bf5535f6
commit 562caeb10b
12 changed files with 110 additions and 34 deletions

View File

@@ -1,25 +1 @@
# -*- coding: utf-8 -*-
"""
gismo sh-edraft Gismo
~~~~~~~~~~~~~~~~~~~
sh-edraft Dicord bot Gismo
:copyright: (c) 2021 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'modules_core'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2021 - 2022 sh-edraft.de'
__version__ = '0.1.0'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='0', minor='1', micro='0')
# imports

View File

@@ -0,0 +1 @@
# imports

View File

@@ -0,0 +1,7 @@
from abc import ABC, abstractmethod
class ModuleABC(ABC):
@abstractmethod
def __init__(self): pass

View File

@@ -0,0 +1,14 @@
from abc import ABC, abstractmethod
from codecs import register
class ModuleServiceABC(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def register(self): pass
@abstractmethod
def start_modules(self): pass

View File

@@ -0,0 +1 @@
# imports

View File

@@ -0,0 +1,21 @@
from cpl_core.environment.application_environment_abc import \
ApplicationEnvironmentABC
from cpl_core.logging import LoggerABC
from cpl_query.extension import List
from modules_core.abc.module_abc import ModuleABC
from modules_core.abc.module_service_abc import ModuleServiceABC
class ModuleService(ModuleServiceABC):
def __init__(self, logger: LoggerABC, env: ApplicationEnvironmentABC):
self._logger = logger
self._env = env
self._modules: List[ModuleABC] = List()
def register(self, module: ModuleABC):
self._modules.append(module)
def start_modules(self):
self._modules.for_each(lambda m: m.echo())