2021.4 #19
2
cpl.json
2
cpl.json
@ -4,7 +4,7 @@
|
||||
"Version": {
|
||||
"Major": "2021",
|
||||
"Minor": "04",
|
||||
"Micro": "01-13"
|
||||
"Micro": "01-14"
|
||||
},
|
||||
"Author": "Sven Heidemann",
|
||||
"AuthorEmail": "sven.heidemann@sh-edraft.de",
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'sh_cpl.cpl'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,17 +15,17 @@ __title__ = 'cpl.application'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
from .application_abc import ApplicationABC
|
||||
from .application_host import ApplicationHost
|
||||
from .application_host_abc import ApplicationHostABC
|
||||
from .application_builder import ApplicationBuilder
|
||||
from .application_builder_abc import ApplicationBuilderABC
|
||||
from .application_runtime import ApplicationRuntime
|
||||
from .application_runtime_abc import ApplicationRuntimeABC
|
||||
from .startup_abc import StartupABC
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -1,52 +1,33 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Type, Optional
|
||||
from typing import Optional
|
||||
|
||||
from cpl.application.application_host_abc import ApplicationHostABC
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.application.startup_abc import StartupABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.console.console import Console
|
||||
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
|
||||
|
||||
class ApplicationABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
"""
|
||||
ABC of application
|
||||
"""
|
||||
self._startup: Optional[StartupABC] = None
|
||||
self._app_host: Optional[ApplicationHostABC] = None
|
||||
self._configuration: Optional[ConfigurationABC] = None
|
||||
self._runtime: Optional[ApplicationRuntimeABC] = None
|
||||
self._services: Optional[ServiceProviderABC] = None
|
||||
|
||||
def use_startup(self, startup: Type[StartupABC]):
|
||||
"""
|
||||
Sets the used startup class
|
||||
:param startup:
|
||||
:return:
|
||||
"""
|
||||
self._startup = startup()
|
||||
|
||||
def build(self):
|
||||
"""
|
||||
Creates application host and runtime
|
||||
:return:
|
||||
"""
|
||||
if self._startup is not None:
|
||||
self._app_host = self._startup.create_application_host()
|
||||
self._runtime = self._app_host.application_runtime
|
||||
self._configuration = self._startup.create_configuration()
|
||||
self._services = self._startup.create_services()
|
||||
self._configuration: Optional[ConfigurationABC] = config
|
||||
self._runtime: Optional[ApplicationRuntimeABC] = runtime
|
||||
self._services: Optional[ServiceProviderABC] = services
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Entry point
|
||||
:return:
|
||||
"""
|
||||
self.configure()
|
||||
self.main()
|
||||
try:
|
||||
self.configure()
|
||||
self.main()
|
||||
except KeyboardInterrupt:
|
||||
Console.close()
|
||||
|
||||
@abstractmethod
|
||||
def configure(self):
|
||||
|
41
src/cpl/application/application_builder.py
Normal file
41
src/cpl/application/application_builder.py
Normal file
@ -0,0 +1,41 @@
|
||||
from typing import Type, Optional
|
||||
|
||||
from cpl.application.application_abc import ApplicationABC
|
||||
from cpl.application.application_builder_abc import ApplicationBuilderABC
|
||||
from cpl.application.application_runtime import ApplicationRuntime
|
||||
from cpl.application.startup_abc import StartupABC
|
||||
from cpl.configuration import Configuration
|
||||
from cpl.dependency_injection import ServiceProvider
|
||||
|
||||
|
||||
class ApplicationBuilder(ApplicationBuilderABC):
|
||||
|
||||
def __init__(self, app: Type[ApplicationABC]):
|
||||
"""
|
||||
Builder class for application
|
||||
"""
|
||||
ApplicationBuilderABC.__init__(self, app)
|
||||
self._startup: Optional[StartupABC] = None
|
||||
|
||||
self._configuration = Configuration()
|
||||
self._runtime = ApplicationRuntime()
|
||||
self._services = ServiceProvider(self._configuration, self._runtime)
|
||||
|
||||
def use_startup(self, startup: Type[StartupABC]):
|
||||
"""
|
||||
Sets the used startup class
|
||||
:param startup:
|
||||
:return:
|
||||
"""
|
||||
self._startup = startup(self._configuration, self._runtime, self._services)
|
||||
|
||||
def build(self) -> ApplicationABC:
|
||||
"""
|
||||
Creates application host and runtime
|
||||
:return:
|
||||
"""
|
||||
if self._startup is not None:
|
||||
self._startup.configure_configuration()
|
||||
self._startup.configure_services()
|
||||
|
||||
return self._app(self._configuration, self._runtime, self._services)
|
31
src/cpl/application/application_builder_abc.py
Normal file
31
src/cpl/application/application_builder_abc.py
Normal file
@ -0,0 +1,31 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Type
|
||||
|
||||
from cpl.application.application_abc import ApplicationABC
|
||||
from cpl.application.startup_abc import StartupABC
|
||||
|
||||
|
||||
class ApplicationBuilderABC(ABC):
|
||||
|
||||
def __init__(self, app: Type[ApplicationABC]):
|
||||
"""
|
||||
ABC of application builder
|
||||
"""
|
||||
self._app = app
|
||||
|
||||
@abstractmethod
|
||||
def use_startup(self, startup: Type[StartupABC]):
|
||||
"""
|
||||
Sets the used startup class
|
||||
:param startup:
|
||||
:return:
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def build(self) -> ApplicationABC:
|
||||
"""
|
||||
Creates application host and runtime
|
||||
:return:
|
||||
"""
|
||||
pass
|
@ -1,38 +0,0 @@
|
||||
from collections import Callable
|
||||
|
||||
from cpl.application.application_host_abc import ApplicationHostABC
|
||||
from cpl.application.application_runtime import ApplicationRuntime
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.configuration.configuration import Configuration
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.dependency_injection.service_provider import ServiceProvider
|
||||
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
|
||||
|
||||
class ApplicationHost(ApplicationHostABC):
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Representation of application host
|
||||
"""
|
||||
ApplicationHostABC.__init__(self)
|
||||
|
||||
# Init
|
||||
self._config = Configuration()
|
||||
self._app_runtime = ApplicationRuntime(self._config)
|
||||
self._services = ServiceProvider(self._app_runtime)
|
||||
|
||||
@property
|
||||
def configuration(self) -> ConfigurationABC:
|
||||
return self._config
|
||||
|
||||
@property
|
||||
def application_runtime(self) -> ApplicationRuntimeABC:
|
||||
return self._app_runtime
|
||||
|
||||
@property
|
||||
def services(self) -> ServiceProviderABC:
|
||||
return self._services
|
||||
|
||||
def console_argument_error_function(self, function: Callable):
|
||||
self._config.argument_error_function = function
|
@ -1,37 +0,0 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from collections import Callable
|
||||
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
|
||||
|
||||
class ApplicationHostABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
"""
|
||||
ABC for application host
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def configuration(self) -> ConfigurationABC: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def application_runtime(self) -> ApplicationRuntimeABC: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def services(self) -> ServiceProviderABC: pass
|
||||
|
||||
@abstractmethod
|
||||
def console_argument_error_function(self, function: Callable):
|
||||
"""
|
||||
Defines function to call when a argument error is detected
|
||||
:param function:
|
||||
:return:
|
||||
"""
|
||||
pass
|
@ -2,28 +2,21 @@ import pathlib
|
||||
from datetime import datetime
|
||||
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
|
||||
|
||||
class ApplicationRuntime(ApplicationRuntimeABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC):
|
||||
def __init__(self):
|
||||
"""
|
||||
Representation of the application runtime
|
||||
:param config:
|
||||
"""
|
||||
ApplicationRuntimeABC.__init__(self)
|
||||
|
||||
self._app_configuration = config
|
||||
self._start_time: datetime = datetime.now()
|
||||
self._end_time: datetime = datetime.now()
|
||||
self._working_directory = pathlib.Path().absolute()
|
||||
self._runtime_directory = pathlib.Path(__file__).parent.absolute()
|
||||
|
||||
@property
|
||||
def configuration(self) -> ConfigurationABC:
|
||||
return self._app_configuration
|
||||
|
||||
@property
|
||||
def start_time(self) -> datetime:
|
||||
return self._start_time
|
||||
|
@ -1,8 +1,6 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
|
||||
|
||||
class ApplicationRuntimeABC(ABC):
|
||||
|
||||
@ -13,10 +11,6 @@ class ApplicationRuntimeABC(ABC):
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def configuration(self) -> ConfigurationABC: pass
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def start_time(self) -> datetime: pass
|
||||
|
@ -1,6 +1,6 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from cpl.application.application_host_abc import ApplicationHostABC
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
|
||||
@ -8,22 +8,17 @@ from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
class StartupABC(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
"""
|
||||
ABC for a startup class
|
||||
"""
|
||||
pass
|
||||
|
||||
self._configuration = config
|
||||
self._application_runtime = runtime
|
||||
self._services = services
|
||||
|
||||
@abstractmethod
|
||||
def create_application_host(self) -> ApplicationHostABC:
|
||||
"""
|
||||
Creates application host with specific attributes
|
||||
:return: application host
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def create_configuration(self) -> ConfigurationABC:
|
||||
def configure_configuration(self) -> ConfigurationABC:
|
||||
"""
|
||||
Creates configuration of application
|
||||
:return: configuration
|
||||
@ -31,7 +26,7 @@ class StartupABC(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def create_services(self) -> ServiceProviderABC:
|
||||
def configure_services(self) -> ServiceProviderABC:
|
||||
"""
|
||||
Creates service provider
|
||||
:return: service provider
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.configuration'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -27,4 +27,4 @@ from .configuration_variable_name_enum import ConfigurationVariableNameEnum
|
||||
from .console_argument import ConsoleArgument
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.console'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -27,4 +27,4 @@ from .foreground_color_enum import ForegroundColorEnum
|
||||
from .spinner_thread import SpinnerThread
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -432,7 +432,7 @@ class Console:
|
||||
return_value = call(*args, **kwargs)
|
||||
except KeyboardInterrupt:
|
||||
spinner.exit()
|
||||
exit()
|
||||
cls.close()
|
||||
|
||||
spinner.stop_spinning()
|
||||
cls.set_hold_back(False)
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.database'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -25,4 +25,4 @@ from .database_settings import DatabaseSettings
|
||||
from .database_settings_name_enum import DatabaseSettingsNameEnum
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.database.connection'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -24,4 +24,4 @@ from .database_connection import DatabaseConnection
|
||||
from .database_connection_abc import DatabaseConnectionABC
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.database.context'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -24,4 +24,4 @@ from .database_context import DatabaseContext
|
||||
from .database_context_abc import DatabaseContextABC
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.dependency_injection'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -25,4 +25,4 @@ from .service_provider import ServiceProvider
|
||||
from .service_provider_abc import ServiceProviderABC
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -13,13 +13,14 @@ from cpl.environment.environment_abc import ApplicationEnvironmentABC
|
||||
|
||||
class ServiceProvider(ServiceProviderABC):
|
||||
|
||||
def __init__(self, app_runtime: ApplicationRuntimeABC):
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC):
|
||||
"""
|
||||
Service for service providing
|
||||
:param app_runtime:
|
||||
:param runtime:
|
||||
"""
|
||||
ServiceProviderABC.__init__(self)
|
||||
self._app_runtime: ApplicationRuntimeABC = app_runtime
|
||||
self._configuration: ConfigurationABC = config
|
||||
self._runtime: ApplicationRuntimeABC = runtime
|
||||
self._database_context: Optional[DatabaseContextABC] = None
|
||||
|
||||
self._transient_services: dict[Type[ServiceABC], Callable[ServiceABC]] = {}
|
||||
@ -38,19 +39,19 @@ class ServiceProvider(ServiceProviderABC):
|
||||
parameter = param[1]
|
||||
if parameter.name != 'self' and parameter.annotation != Parameter.empty:
|
||||
if issubclass(parameter.annotation, ApplicationRuntimeABC):
|
||||
params.append(self._app_runtime)
|
||||
params.append(self._runtime)
|
||||
|
||||
elif issubclass(parameter.annotation, ApplicationEnvironmentABC):
|
||||
params.append(self._app_runtime.configuration.environment)
|
||||
params.append(self._configuration.environment)
|
||||
|
||||
elif issubclass(parameter.annotation, DatabaseContextABC):
|
||||
params.append(self._database_context)
|
||||
|
||||
elif issubclass(parameter.annotation, ConfigurationModelABC):
|
||||
params.append(self._app_runtime.configuration.get_configuration(parameter.annotation))
|
||||
params.append(self._configuration.get_configuration(parameter.annotation))
|
||||
|
||||
elif issubclass(parameter.annotation, ConfigurationABC):
|
||||
params.append(self._app_runtime.configuration)
|
||||
params.append(self._configuration)
|
||||
|
||||
elif issubclass(parameter.annotation, ServiceProviderABC):
|
||||
params.append(self)
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.environment'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -25,4 +25,4 @@ from .environment_name_enum import EnvironmentNameEnum
|
||||
from .application_environment import ApplicationEnvironment
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.logging'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -27,4 +27,4 @@ from .logging_settings import LoggingSettings
|
||||
from .logging_settings_name_enum import LoggingSettingsNameEnum
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.mailing'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -27,4 +27,4 @@ from .email_client_settings import EMailClientSettings
|
||||
from .email_client_settings_name_enum import EMailClientSettingsNameEnum
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.time'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -24,4 +24,4 @@ from .time_format_settings import TimeFormatSettings
|
||||
from .time_format_settings_names_enum import TimeFormatSettingsNamesEnum
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl.utils'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -25,4 +25,4 @@ from .string import String
|
||||
from .pip import Pip
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'sh_cpl.cpl_cli'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -29,4 +29,4 @@ from .main import main
|
||||
from .startup import Startup
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -1,7 +1,10 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.application.application_abc import ApplicationABC
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.console.console import Console
|
||||
from cpl.dependency_injection import ServiceProviderABC
|
||||
from cpl_cli.command.build_service import BuildService
|
||||
from cpl_cli.command.generate_service import GenerateService
|
||||
from cpl_cli.command.install_service import InstallService
|
||||
@ -19,11 +22,11 @@ from cpl_cli.command.version_service import VersionService
|
||||
|
||||
class CLI(ApplicationABC):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
"""
|
||||
CPL CLI
|
||||
"""
|
||||
ApplicationABC.__init__(self)
|
||||
ApplicationABC.__init__(self, config, runtime, services)
|
||||
|
||||
self._command_handler: Optional[CommandHandler] = None
|
||||
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.command'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -28,4 +28,4 @@ from .publish_service import PublishService
|
||||
from .version_service import VersionService
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.configuration'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -28,4 +28,4 @@ from .version_settings import VersionSettings
|
||||
from .version_settings_name_enum import VersionSettingsNameEnum
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'cpl_cli.live_server'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -1,12 +1,12 @@
|
||||
from cpl.application.application_builder import ApplicationBuilder
|
||||
from cpl_cli.cli import CLI
|
||||
from cpl_cli.startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
cli = CLI()
|
||||
cli.use_startup(Startup)
|
||||
cli.build()
|
||||
cli.run()
|
||||
app_builder = ApplicationBuilder(CLI)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -15,7 +15,7 @@ __title__ = 'cpl_cli.publish'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@ -24,4 +24,4 @@ from .publisher_abc import PublisherABC
|
||||
from .publisher_service import PublisherService
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -1,7 +1,4 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.application.application_host import ApplicationHost
|
||||
from cpl.application.application_host_abc import ApplicationHostABC
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.application.startup_abc import StartupABC
|
||||
from cpl.configuration.console_argument import ConsoleArgument
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
@ -25,28 +22,17 @@ from cpl_cli.publish.publisher_abc import PublisherABC
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
StartupABC.__init__(self, config, runtime, services)
|
||||
|
||||
self._app_host: Optional[ApplicationHostABC] = None
|
||||
self._configuration: Optional[ConfigurationABC] = None
|
||||
self._services: Optional[ServiceProviderABC] = None
|
||||
self._application_runtime.set_runtime_directory(__file__)
|
||||
|
||||
def create_application_host(self) -> ApplicationHostABC:
|
||||
self._app_host = ApplicationHost()
|
||||
def configure_configuration(self) -> ConfigurationABC:
|
||||
self._configuration.argument_error_function = Error.error
|
||||
|
||||
self._app_host.application_runtime.set_runtime_directory(__file__)
|
||||
self._app_host.console_argument_error_function(Error.error)
|
||||
|
||||
self._configuration = self._app_host.configuration
|
||||
self._services = self._app_host.services
|
||||
|
||||
return self._app_host
|
||||
|
||||
def create_configuration(self) -> ConfigurationABC:
|
||||
self._configuration.add_environment_variables('PYTHON_')
|
||||
self._configuration.add_environment_variables('CPL_')
|
||||
self._configuration.add_json_file('appsettings.json', path=self._app_host.application_runtime.runtime_directory,
|
||||
self._configuration.add_json_file('appsettings.json', path=self._application_runtime.runtime_directory,
|
||||
optional=False, output=False)
|
||||
self._configuration.add_console_argument(ConsoleArgument('', 'build', ['b', 'B'], ''))
|
||||
self._configuration.add_console_argument(ConsoleArgument('', 'generate', ['g', 'G'], '', console_arguments=[
|
||||
@ -73,7 +59,7 @@ class Startup(StartupABC):
|
||||
|
||||
return self._configuration
|
||||
|
||||
def create_services(self) -> ServiceProviderABC:
|
||||
def configure_services(self) -> ServiceProviderABC:
|
||||
self._services.add_singleton(CommandHandler)
|
||||
|
||||
self._services.add_transient(PublisherABC, PublisherService)
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.build'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.generate'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console.src'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -12,13 +12,16 @@ class ApplicationTemplate(TemplateFileABC):
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application.application_abc import ApplicationABC
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.console.console import Console
|
||||
|
||||
|
||||
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self):
|
||||
ApplicationABC.__init__(self)
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, runtime, services)
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
@ -11,15 +11,16 @@ class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
from startup import Startup
|
||||
from cpl.application.application_builder import ApplicationBuilder
|
||||
|
||||
from application import Application
|
||||
from startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
app = Application()
|
||||
app.use_startup(Startup)
|
||||
app.build()
|
||||
app.run()
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -47,13 +48,14 @@ class MainWithApplicationHostTemplate(TemplateFileABC):
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application.application_builder import ApplicationBuilder
|
||||
|
||||
from application import Application
|
||||
|
||||
|
||||
def main():
|
||||
app = Application()
|
||||
app.build()
|
||||
app.run()
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -11,10 +11,7 @@ class StartupTemplate(TemplateFileABC):
|
||||
self._name = 'startup.py'
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
from typing import Optional
|
||||
|
||||
from cpl.application.application_host import ApplicationHost
|
||||
from cpl.application.application_host_abc import ApplicationHostABC
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.application.startup_abc import StartupABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
@ -22,28 +19,15 @@ class StartupTemplate(TemplateFileABC):
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
self._app_host: Optional[ApplicationHostABC] = None
|
||||
self._configuration: Optional[ConfigurationABC] = None
|
||||
self._services: Optional[ServiceProviderABC] = None
|
||||
|
||||
def create_application_host(self) -> ApplicationHostABC:
|
||||
self._app_host = ApplicationHost()
|
||||
self._configuration = self._app_host.configuration
|
||||
self._services = self._app_host.services
|
||||
return self._app_host
|
||||
|
||||
def create_configuration(self) -> ConfigurationABC:
|
||||
pass
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
StartupABC.__init__(self, config, runtime, services)
|
||||
|
||||
def configure_configuration(self) -> ConfigurationABC:
|
||||
return self._configuration
|
||||
|
||||
def create_services(self) -> ServiceProviderABC:
|
||||
pass
|
||||
|
||||
def configure_services(self) -> ServiceProviderABC:
|
||||
return self._services
|
||||
|
||||
""")
|
||||
|
||||
@property
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console.src.tests'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.publish'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.1.post13'
|
||||
__version__ = '2021.4.1.post14'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-13')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='01-14')
|
||||
|
@ -2,7 +2,10 @@ import time
|
||||
from typing import Optional
|
||||
|
||||
from cpl.application.application_abc import ApplicationABC
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.console.console import Console
|
||||
from cpl.dependency_injection.service_provider_abc import ServiceProviderABC
|
||||
from cpl.logging.logger_abc import LoggerABC
|
||||
from cpl.mailing.email import EMail
|
||||
from cpl.mailing.email_client_abc import EMailClientABC
|
||||
@ -10,8 +13,8 @@ from cpl.mailing.email_client_abc import EMailClientABC
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self):
|
||||
ApplicationABC.__init__(self)
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, runtime, services)
|
||||
self._logger: Optional[LoggerABC] = None
|
||||
self._mailer: Optional[EMailClientABC] = None
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
from cpl.application.application_builder import ApplicationBuilder
|
||||
from tests.custom.general.application import Application
|
||||
from tests.custom.general.startup import Startup
|
||||
|
||||
|
||||
def main():
|
||||
app = Application()
|
||||
app.use_startup(Startup)
|
||||
app.build()
|
||||
app.run()
|
||||
app_builder = ApplicationBuilder(Application)
|
||||
app_builder.use_startup(Startup)
|
||||
app_builder.build().run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,7 +1,4 @@
|
||||
from typing import Optional
|
||||
|
||||
from cpl.application.application_host import ApplicationHost
|
||||
from cpl.application.application_host_abc import ApplicationHostABC
|
||||
from cpl.application.application_runtime_abc import ApplicationRuntimeABC
|
||||
from cpl.application.startup_abc import StartupABC
|
||||
from cpl.configuration.configuration_abc import ConfigurationABC
|
||||
from cpl.database.context.database_context import DatabaseContext
|
||||
@ -16,20 +13,10 @@ from cpl.utils.credential_manager import CredentialManager
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self):
|
||||
StartupABC.__init__(self)
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
StartupABC.__init__(self, config, runtime, services)
|
||||
|
||||
self._app_host: Optional[ApplicationHostABC] = None
|
||||
self._configuration: Optional[ConfigurationABC] = None
|
||||
self._services: Optional[ServiceProviderABC] = None
|
||||
|
||||
def create_application_host(self) -> ApplicationHostABC:
|
||||
self._app_host = ApplicationHost()
|
||||
self._configuration = self._app_host.configuration
|
||||
self._services = self._app_host.services
|
||||
return self._app_host
|
||||
|
||||
def create_configuration(self) -> ConfigurationABC:
|
||||
def configure_configuration(self) -> ConfigurationABC:
|
||||
self._configuration.add_environment_variables('PYTHON_')
|
||||
self._configuration.add_environment_variables('CPL_')
|
||||
self._configuration.add_console_arguments()
|
||||
@ -39,7 +26,7 @@ class Startup(StartupABC):
|
||||
|
||||
return self._configuration
|
||||
|
||||
def create_services(self) -> ServiceProviderABC:
|
||||
def configure_services(self) -> ServiceProviderABC:
|
||||
# Create and connect to database
|
||||
db_settings: DatabaseSettings = self._configuration.get_configuration(DatabaseSettings)
|
||||
self._services.add_db_context(DatabaseContext)
|
||||
|
Loading…
Reference in New Issue
Block a user