Updated docs

This commit is contained in:
2023-02-20 15:55:20 +01:00
parent 48d0daabf5
commit 9e28dce5ce
632 changed files with 10917 additions and 6775 deletions

View File

@@ -1,10 +1,7 @@
from cpl_cli.abc.generate_schematic_abc import GenerateSchematicABC
class Custom(GenerateSchematicABC):
def __init__(self, *args: str):
GenerateSchematicABC.__init__(self, *args)
@@ -20,8 +17,4 @@ class Custom(GenerateSchematicABC):
@classmethod
def register(cls):
GenerateSchematicABC.register(
cls,
'custom',
['cm', 'CM']
)
GenerateSchematicABC.register(cls, "custom", ["cm", "CM"])

View File

@@ -12,7 +12,6 @@ from test_service import TestService
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
self._logger: Optional[LoggerABC] = None
@@ -20,12 +19,12 @@ class Application(ApplicationABC):
def test_send_mail(self):
mail = EMail()
mail.add_header('Mime-Version: 1.0')
mail.add_header('Content-Type: text/plain; charset=utf-8')
mail.add_header('Content-Transfer-Encoding: quoted-printable')
mail.add_receiver('sven.heidemann@sh-edraft.de')
mail.subject = f'Test - {self._configuration.environment.host_name}'
mail.body = 'Dies ist ein Test :D'
mail.add_header("Mime-Version: 1.0")
mail.add_header("Content-Type: text/plain; charset=utf-8")
mail.add_header("Content-Transfer-Encoding: quoted-printable")
mail.add_receiver("sven.heidemann@sh-edraft.de")
mail.subject = f"Test - {self._configuration.environment.host_name}"
mail.body = "Dies ist ein Test :D"
self._mailer.send_mail(mail)
@staticmethod
@@ -39,23 +38,23 @@ class Application(ApplicationABC):
def main(self):
self._configuration.parse_console_arguments(self._services)
if self._configuration.environment.application_name != '':
self._logger.header(f'{self._configuration.environment.application_name}:')
self._logger.debug(__name__, f'Args: {self._configuration.additional_arguments}')
self._logger.debug(__name__, f'Host: {self._configuration.environment.host_name}')
self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}')
self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}')
Console.spinner('Test', self._wait, 2, spinner_foreground_color='red')
if self._configuration.environment.application_name != "":
self._logger.header(f"{self._configuration.environment.application_name}:")
self._logger.debug(__name__, f"Args: {self._configuration.additional_arguments}")
self._logger.debug(__name__, f"Host: {self._configuration.environment.host_name}")
self._logger.debug(__name__, f"Environment: {self._configuration.environment.environment_name}")
self._logger.debug(__name__, f"Customer: {self._configuration.environment.customer}")
Console.spinner("Test", self._wait, 2, spinner_foreground_color="red")
test: TestService = self._services.get_service(TestService)
ip_pipe: IPAddressPipe = self._services.get_service(IPAddressPipe)
test.run()
test2: TestService = self._services.get_service(TestService)
ip_pipe2: IPAddressPipe = self._services.get_service(IPAddressPipe)
Console.write_line(f'DI working: {test == test2 and ip_pipe != ip_pipe2}')
Console.write_line(f"DI working: {test == test2 and ip_pipe != ip_pipe2}")
Console.write_line(self._services.get_service(LoggerABC))
scope = self._services.create_scope()
Console.write_line('scope', scope)
Console.write_line("scope", scope)
with self._services.create_scope() as s:
Console.write_line('with scope', s)
Console.write_line("with scope", s)
self.test_send_mail()

View File

@@ -11,16 +11,16 @@ sh-edraft Common Python library
"""
__title__ = 'general.arguments'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1'
__title__ = "general.arguments"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2020 - 2021 sh-edraft.de"
__version__ = "2021.4.1"
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01')
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="2021", minor="04", micro="01")

View File

@@ -4,12 +4,11 @@ from cpl_core.environment import ApplicationEnvironmentABC
class GenerateArgument(ArgumentExecutableABC):
def __init__(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
ArgumentExecutableABC.__init__(self)
self._config = config
self._env = env
def execute(self, args: list[str]):
Console.error('Generate:')
Console.error("Generate:")
Console.write_line(args, self._env.environment_name)

View File

@@ -3,9 +3,8 @@ from cpl_core.console import Console
class InstallArgument(ArgumentExecutableABC):
def __init__(self):
ArgumentExecutableABC.__init__(self)
def execute(self, args: list[str]):
Console.write_line('Install:', args)
Console.write_line("Install:", args)

View File

@@ -11,16 +11,16 @@ sh-edraft Common Python library
"""
__title__ = 'general.db'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
__version__ = '2021.4.1'
__title__ = "general.db"
__author__ = "Sven Heidemann"
__license__ = "MIT"
__copyright__ = "Copyright (c) 2020 - 2021 sh-edraft.de"
__version__ = "2021.4.1"
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2021', minor='04', micro='01')
VersionInfo = namedtuple("VersionInfo", "major minor micro")
version_info = VersionInfo(major="2021", minor="04", micro="01")

View File

@@ -15,5 +15,5 @@ def main():
app_builder.build().run()
if __name__ == '__main__':
if __name__ == "__main__":
main()

View File

@@ -7,25 +7,32 @@ from cpl_core.environment import ApplicationEnvironmentABC
class ParameterStartup(StartupExtensionABC):
def __init__(self):
StartupExtensionABC.__init__(self)
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'generate', ['g', 'G'], GenerateArgument) \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'abc', ['a', 'A'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'class', ['c', 'C'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'enum', ['e', 'E'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'service', ['s', 'S'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'settings', ['st', 'ST'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'thread', ['t', 'T'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '-', 'o', ['o', 'O'], '=') \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'virtual', ['v', 'V'])
config.create_console_argument(ArgumentTypeEnum.Executable, '', 'install', ['i', 'I'], InstallArgument) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'virtual', ['v', 'V']) \
.add_console_argument(ArgumentTypeEnum.Flag, '--', 'simulate', ['s', 'S'])
config.create_console_argument(
ArgumentTypeEnum.Executable, "", "generate", ["g", "G"], GenerateArgument
).add_console_argument(ArgumentTypeEnum.Variable, "", "abc", ["a", "A"], " ").add_console_argument(
ArgumentTypeEnum.Variable, "", "class", ["c", "C"], " "
).add_console_argument(
ArgumentTypeEnum.Variable, "", "enum", ["e", "E"], " "
).add_console_argument(
ArgumentTypeEnum.Variable, "", "service", ["s", "S"], " "
).add_console_argument(
ArgumentTypeEnum.Variable, "", "settings", ["st", "ST"], " "
).add_console_argument(
ArgumentTypeEnum.Variable, "", "thread", ["t", "T"], " "
).add_console_argument(
ArgumentTypeEnum.Variable, "-", "o", ["o", "O"], "="
).add_console_argument(
ArgumentTypeEnum.Flag, "--", "virtual", ["v", "V"]
)
config.create_console_argument(
ArgumentTypeEnum.Executable, "", "install", ["i", "I"], InstallArgument
).add_console_argument(ArgumentTypeEnum.Flag, "--", "virtual", ["v", "V"]).add_console_argument(
ArgumentTypeEnum.Flag, "--", "simulate", ["s", "S"]
)
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
services \
.add_transient(GenerateArgument) \
.add_singleton(InstallArgument)
services.add_transient(GenerateArgument).add_singleton(InstallArgument)

View File

@@ -9,16 +9,15 @@ from test_service import TestService
class Startup(StartupABC):
def __init__(self):
StartupABC.__init__(self)
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC) -> ConfigurationABC:
config.add_environment_variables('PYTHON_')
config.add_environment_variables('CPLT_')
config.add_json_file(f'appsettings.json')
config.add_json_file(f'appsettings.{config.environment.environment_name}.json')
config.add_json_file(f'appsettings.{config.environment.host_name}.json', optional=True)
config.add_environment_variables("PYTHON_")
config.add_environment_variables("CPLT_")
config.add_json_file(f"appsettings.json")
config.add_json_file(f"appsettings.{config.environment.environment_name}.json")
config.add_json_file(f"appsettings.{config.environment.host_name}.json", optional=True)
return config

View File

@@ -5,9 +5,8 @@ from cpl_core.dependency_injection import ServiceProviderABC
class TestExtension(ApplicationExtensionABC):
def __init__(self):
ApplicationExtensionABC.__init__(self)
def run(self, config: ConfigurationABC, services: ServiceProviderABC):
Console.write_line('Hello World from App Extension')
Console.write_line("Hello World from App Extension")

View File

@@ -4,13 +4,11 @@ from cpl_core.pipes.ip_address_pipe import IPAddressPipe
class TestService:
def __init__(self, provider: ServiceProviderABC, ip_pipe: IPAddressPipe):
self._provider = provider
self._ip_pipe = ip_pipe
def run(self):
Console.write_line('Hello World!', self._provider)
Console.write_line("Hello World!", self._provider)
ip = [192, 168, 178, 30]
Console.write_line(ip, self._ip_pipe.transform(ip))

View File

@@ -6,12 +6,11 @@ from cpl_core.environment import ApplicationEnvironmentABC
class TestStartupExtension(StartupExtensionABC):
def __init__(self):
StartupExtensionABC.__init__(self)
def configure_configuration(self, config: ConfigurationABC, env: ApplicationEnvironmentABC):
Console.write_line('config')
Console.write_line("config")
def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC):
Console.write_line('services')
Console.write_line("services")

View File

@@ -1,4 +1,3 @@
class Custom:
def __init__(self):
print('hello')
print("hello")