Refactored code

This commit is contained in:
2021-03-03 10:47:52 +01:00
parent a7c2946ba5
commit 68c136a16f
205 changed files with 2207 additions and 1010 deletions

View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.hosting
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.hosting'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .application_host import ApplicationHost
from .application_runtime import ApplicationRuntime
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@@ -0,0 +1,46 @@
import atexit
from datetime import datetime
from sh_edraft.configuration.configuration import Configuration
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
from sh_edraft.hosting.application_runtime import ApplicationRuntime
from sh_edraft.hosting.base.application_host_base import ApplicationHostBase
from sh_edraft.service.providing.service_provider import ServiceProvider
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
from sh_edraft.console.console import Console
class ApplicationHost(ApplicationHostBase):
def __init__(self):
ApplicationHostBase.__init__(self)
# Init
self._config = Configuration()
self._app_runtime = ApplicationRuntime(self._config)
self._services = ServiceProvider(self._app_runtime)
# Create
self._config.create()
self._services.create()
# Set vars
self._start_time: datetime = datetime.now()
self._end_time: datetime = datetime.now()
atexit.register(Console.close)
@property
def configuration(self) -> ConfigurationBase:
return self._config
@property
def application_runtime(self) -> ApplicationRuntimeBase:
return self._app_runtime
@property
def services(self) -> ServiceProviderBase:
return self._services
def create(self): pass

View File

@@ -0,0 +1,38 @@
from datetime import datetime
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
class ApplicationRuntime(ApplicationRuntimeBase):
def __init__(self, config: ConfigurationBase):
ApplicationRuntimeBase.__init__(self)
self._app_configuration = config
self._start_time: datetime = datetime.now()
self._end_time: datetime = datetime.now()
@property
def configuration(self) -> ConfigurationBase:
return self._app_configuration
@property
def start_time(self) -> datetime:
return self._start_time
@start_time.setter
def start_time(self, start_time: datetime):
self._start_time = start_time
@property
def end_time(self) -> datetime:
return self._end_time
@end_time.setter
def end_time(self, end_time: datetime):
self._end_time = end_time
@property
def date_time_now(self) -> datetime:
return datetime.now()

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.hosting.base
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.hosting.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
from .application_base import ApplicationBase
from .application_host_base import ApplicationHostBase
from .application_runtime_base import ApplicationRuntimeBase
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)

View File

@@ -0,0 +1,19 @@
from abc import ABC, abstractmethod
class ApplicationBase(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def create_application_host(self): pass
@abstractmethod
def create_configuration(self): pass
@abstractmethod
def create_services(self): pass
@abstractmethod
def main(self): pass

View File

@@ -0,0 +1,26 @@
from abc import ABC, abstractmethod
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase
class ApplicationHostBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def configuration(self) -> ConfigurationBase: pass
@property
@abstractmethod
def application_runtime(self) -> ApplicationRuntimeBase: pass
@property
@abstractmethod
def services(self) -> ServiceProviderBase: pass
@abstractmethod
def create(self): pass

View File

@@ -0,0 +1,34 @@
from abc import ABC, abstractmethod
from datetime import datetime
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
class ApplicationRuntimeBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def configuration(self) -> ConfigurationBase: pass
@property
@abstractmethod
def start_time(self) -> datetime: pass
@start_time.setter
@abstractmethod
def start_time(self, start_time: datetime): pass
@property
@abstractmethod
def end_time(self): pass
@end_time.setter
@abstractmethod
def end_time(self, end_time: datetime): pass
@property
@abstractmethod
def date_time_now(self) -> datetime: pass

View File

@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
"""
sh_edraft.hosting.model
~~~~~~~~~~~~~~~~~~~
:copyright: (c) 2020 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'sh_edraft.hosting.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
__version__ = '2020.12.9'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major=2020, minor=12, micro=9)