From cfb8838c733d3e652ee744ed64efea415d4d147a Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 May 2022 20:27:58 +0200 Subject: [PATCH] Added default pipes --- .../_templates/generate/pipe_template.py | 2 +- src/cpl_cli/cli.py | 2 +- src/cpl_cli/startup_argument_extension.py | 8 ++--- src/cpl_core/__init__.py | 4 +-- src/cpl_core/application/__init__.py | 4 +-- src/cpl_core/application/application_abc.py | 2 +- src/cpl_core/configuration/__init__.py | 4 +-- src/cpl_core/configuration/configuration.py | 5 ++-- src/cpl_core/console/__init__.py | 4 +-- src/cpl_core/database/__init__.py | 4 +-- src/cpl_core/database/connection/__init__.py | 4 +-- src/cpl_core/database/context/__init__.py | 4 +-- src/cpl_core/dependency_injection/__init__.py | 4 +-- .../dependency_injection/service_provider.py | 1 + src/cpl_core/environment/__init__.py | 4 +-- src/cpl_core/logging/__init__.py | 4 +-- src/cpl_core/mailing/__init__.py | 4 +-- src/cpl_core/pipe/first_char_to_lower_pipe.py | 9 ------ src/cpl_core/{pipe => pipes}/__init__.py | 11 +++++-- src/cpl_core/pipes/bool_pipe.py | 9 ++++++ .../pipes/first_char_to_lower_pipe.py | 20 +++++++++++++ src/cpl_core/pipes/first_to_upper_pipe.py | 20 +++++++++++++ src/cpl_core/pipes/ip_address_pipe.py | 24 +++++++++++++++ src/cpl_core/{pipe => pipes}/pipe_abc.py | 0 src/cpl_core/pipes/to_camel_case_pipe.py | 28 ++++++++++++++++++ src/cpl_core/pipes/to_snake_case_pipe.py | 29 +++++++++++++++++++ src/cpl_core/time/__init__.py | 4 +-- src/cpl_core/utils/__init__.py | 4 +-- .../general/src/general/parameter_startup.py | 3 +- .../custom/general/src/general/startup.py | 17 +++++------ .../general/src/general/test_extension.py | 2 +- .../general/src/general/test_service.py | 11 +++---- 32 files changed, 190 insertions(+), 65 deletions(-) delete mode 100644 src/cpl_core/pipe/first_char_to_lower_pipe.py rename src/cpl_core/{pipe => pipes}/__init__.py (60%) create mode 100644 src/cpl_core/pipes/bool_pipe.py create mode 100644 src/cpl_core/pipes/first_char_to_lower_pipe.py create mode 100644 src/cpl_core/pipes/first_to_upper_pipe.py create mode 100644 src/cpl_core/pipes/ip_address_pipe.py rename src/cpl_core/{pipe => pipes}/pipe_abc.py (100%) create mode 100644 src/cpl_core/pipes/to_camel_case_pipe.py create mode 100644 src/cpl_core/pipes/to_snake_case_pipe.py diff --git a/src/cpl_cli/_templates/generate/pipe_template.py b/src/cpl_cli/_templates/generate/pipe_template.py index 129e13ba..bd8b4661 100644 --- a/src/cpl_cli/_templates/generate/pipe_template.py +++ b/src/cpl_cli/_templates/generate/pipe_template.py @@ -14,7 +14,7 @@ class PipeTemplate(TemplateFileABC): self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' self._path = path self._value = textwrap.dedent("""\ - from cpl_core.pipe import PipeABC + from cpl_core.pipes.pipe_abc import PipeABC class $Name(PipeABC): diff --git a/src/cpl_cli/cli.py b/src/cpl_cli/cli.py index af128970..499a5939 100644 --- a/src/cpl_cli/cli.py +++ b/src/cpl_cli/cli.py @@ -5,7 +5,7 @@ from cpl_cli.error import Error from cpl_core.application.application_abc import ApplicationABC from cpl_core.configuration.configuration_abc import ConfigurationABC from cpl_core.console.console import Console -from cpl_core.dependency_injection import ServiceProviderABC +from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC class CLI(ApplicationABC): diff --git a/src/cpl_cli/startup_argument_extension.py b/src/cpl_cli/startup_argument_extension.py index ab7beb4e..29fc300d 100644 --- a/src/cpl_cli/startup_argument_extension.py +++ b/src/cpl_cli/startup_argument_extension.py @@ -17,12 +17,12 @@ from cpl_cli.command.version_service import VersionService from cpl_cli.configuration.workspace_settings import WorkspaceSettings from cpl_cli.validators.project_validator import ProjectValidator from cpl_cli.validators.workspace_validator import WorkspaceValidator -from cpl_core.application import StartupExtensionABC +from cpl_core.application.startup_extension_abc import StartupExtensionABC from cpl_core.configuration.argument_type_enum import ArgumentTypeEnum from cpl_core.configuration.configuration_abc import ConfigurationABC from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC -from cpl_core.environment import ApplicationEnvironmentABC -from cpl_core.utils import String +from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC +from cpl_core.utils.string import String class StartupArgumentExtension(StartupExtensionABC): @@ -66,7 +66,7 @@ class StartupArgumentExtension(StartupExtensionABC): .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, '', 'pipe', ['p', 'P'], ' ') \ + .add_console_argument(ArgumentTypeEnum.Variable, '', 'pipes', ['p', 'P'], ' ') \ .add_console_argument(ArgumentTypeEnum.Variable, '', 'service', ['s', 'S'], ' ') \ .add_console_argument(ArgumentTypeEnum.Variable, '', 'settings', ['st', 'ST'], ' ') \ .add_console_argument(ArgumentTypeEnum.Variable, '', 'thread', ['t', 'T'], ' ') \ diff --git a/src/cpl_core/__init__.py b/src/cpl_core/__init__.py index f6a6761f..3fb3894e 100644 --- a/src/cpl_core/__init__.py +++ b/src/cpl_core/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_core' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' from collections import namedtuple # imports: VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/application/__init__.py b/src/cpl_core/application/__init__.py index 641e09f3..59986ba6 100644 --- a/src/cpl_core/application/__init__.py +++ b/src/cpl_core/application/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.application' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' from collections import namedtuple @@ -28,4 +28,4 @@ from .startup_abc import StartupABC from .startup_extension_abc import StartupExtensionABC VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/application/application_abc.py b/src/cpl_core/application/application_abc.py index 037a73d2..06e01e24 100644 --- a/src/cpl_core/application/application_abc.py +++ b/src/cpl_core/application/application_abc.py @@ -4,7 +4,7 @@ from typing import Optional from cpl_core.configuration.configuration_abc import ConfigurationABC from cpl_core.console.console import Console from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC -from cpl_core.environment import ApplicationEnvironmentABC +from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC class ApplicationABC(ABC): diff --git a/src/cpl_core/configuration/__init__.py b/src/cpl_core/configuration/__init__.py index e0fd7816..a7033c79 100644 --- a/src/cpl_core/configuration/__init__.py +++ b/src/cpl_core/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' from collections import namedtuple @@ -34,4 +34,4 @@ from .validator_abc import ValidatorABC from .variable_argument import VariableArgument VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/configuration/configuration.py b/src/cpl_core/configuration/configuration.py index c0dd8302..3de4fbc2 100644 --- a/src/cpl_core/configuration/configuration.py +++ b/src/cpl_core/configuration/configuration.py @@ -1,13 +1,12 @@ import json import os import sys -import traceback from collections.abc import Callable from typing import Union, Type, Optional -from cpl_cli.command_abc import CommandABC from cpl_core.configuration.argument_abc import ArgumentABC from cpl_core.configuration.argument_builder import ArgumentBuilder +from cpl_core.configuration.argument_executable_abc import ArgumentExecutableABC from cpl_core.configuration.argument_type_enum import ArgumentTypeEnum from cpl_core.configuration.configuration_abc import ConfigurationABC from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC @@ -306,7 +305,7 @@ class Configuration(ConfigurationABC): if abort: continue - cmd: CommandABC = services.get_service(exe.executable_type) + cmd: ArgumentExecutableABC = services.get_service(exe.executable_type) self.add_configuration('ACTIVE_EXECUTABLE', exe.name) cmd.execute(self._additional_arguments) prevent = exe.prevent_next_executable diff --git a/src/cpl_core/console/__init__.py b/src/cpl_core/console/__init__.py index fe05277d..1fa33ae9 100644 --- a/src/cpl_core/console/__init__.py +++ b/src/cpl_core/console/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.console' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' 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='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/database/__init__.py b/src/cpl_core/database/__init__.py index c0c1ebf1..138e67f9 100644 --- a/src/cpl_core/database/__init__.py +++ b/src/cpl_core/database/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.database' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' from collections import namedtuple @@ -25,4 +25,4 @@ from .database_settings import DatabaseSettings from .table_abc import TableABC VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/database/connection/__init__.py b/src/cpl_core/database/connection/__init__.py index 5815d9d6..524aac46 100644 --- a/src/cpl_core/database/connection/__init__.py +++ b/src/cpl_core/database/connection/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.database.connection' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' 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='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/database/context/__init__.py b/src/cpl_core/database/context/__init__.py index c8e89de1..6f7e96d5 100644 --- a/src/cpl_core/database/context/__init__.py +++ b/src/cpl_core/database/context/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.database.context' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' 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='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/dependency_injection/__init__.py b/src/cpl_core/dependency_injection/__init__.py index afe969a5..0f407f7c 100644 --- a/src/cpl_core/dependency_injection/__init__.py +++ b/src/cpl_core/dependency_injection/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.dependency_injection' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' from collections import namedtuple @@ -30,4 +30,4 @@ from .service_provider import ServiceProvider from .service_provider_abc import ServiceProviderABC VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/dependency_injection/service_provider.py b/src/cpl_core/dependency_injection/service_provider.py index 39f298b7..45687060 100644 --- a/src/cpl_core/dependency_injection/service_provider.py +++ b/src/cpl_core/dependency_injection/service_provider.py @@ -4,6 +4,7 @@ from typing import Optional from cpl_core.configuration.configuration_abc import ConfigurationABC from cpl_core.configuration.configuration_model_abc import ConfigurationModelABC +from cpl_core.console import Console from cpl_core.database.context.database_context_abc import DatabaseContextABC from cpl_core.dependency_injection.scope_abc import ScopeABC from cpl_core.dependency_injection.scope_builder import ScopeBuilder diff --git a/src/cpl_core/environment/__init__.py b/src/cpl_core/environment/__init__.py index 59b62db7..49649053 100644 --- a/src/cpl_core/environment/__init__.py +++ b/src/cpl_core/environment/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.environment' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' 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='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/logging/__init__.py b/src/cpl_core/logging/__init__.py index 1d30290c..484ffa50 100644 --- a/src/cpl_core/logging/__init__.py +++ b/src/cpl_core/logging/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.logging' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' 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='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/mailing/__init__.py b/src/cpl_core/mailing/__init__.py index a773c1d1..30f30f15 100644 --- a/src/cpl_core/mailing/__init__.py +++ b/src/cpl_core/mailing/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.mailing' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' 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='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/pipe/first_char_to_lower_pipe.py b/src/cpl_core/pipe/first_char_to_lower_pipe.py deleted file mode 100644 index a9ad59fd..00000000 --- a/src/cpl_core/pipe/first_char_to_lower_pipe.py +++ /dev/null @@ -1,9 +0,0 @@ -from cpl_core.pipe.pipe_abc import PipeABC - - -class FirstCharToLowerPipe(PipeABC): - - def __init__(self): pass - - def transform(self, value: any, *args): - return f'{value[0].lower()}{value[1:]}' diff --git a/src/cpl_core/pipe/__init__.py b/src/cpl_core/pipes/__init__.py similarity index 60% rename from src/cpl_core/pipe/__init__.py rename to src/cpl_core/pipes/__init__.py index b99969fa..87d8e91b 100644 --- a/src/cpl_core/pipe/__init__.py +++ b/src/cpl_core/pipes/__init__.py @@ -11,17 +11,22 @@ sh-edraft Common Python library """ -__title__ = 'cpl_core.pipe' +__title__ = 'cpl_core.pipes' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' from collections import namedtuple # imports: +from .bool_pipe import BoolPipe from .first_char_to_lower_pipe import FirstCharToLowerPipe +from .first_to_upper_pipe import FirstToUpperPipe +from .ip_address_pipe import IPAddressPipe from .pipe_abc import PipeABC +from .to_camel_case_pipe import ToCamelCasePipe +from .to_snake_case_pipe import ToSnakeCasePipe VersionInfo = namedtuple('VersionInfo', 'major minor micro') -version_info = VersionInfo(major='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/pipes/bool_pipe.py b/src/cpl_core/pipes/bool_pipe.py new file mode 100644 index 00000000..daf3ad94 --- /dev/null +++ b/src/cpl_core/pipes/bool_pipe.py @@ -0,0 +1,9 @@ +from cpl_core.pipes.pipe_abc import PipeABC + + +class BoolPipe(PipeABC): + + def __init__(self): pass + + def transform(self, value: bool, *args): + return 'True' if value else 'False' diff --git a/src/cpl_core/pipes/first_char_to_lower_pipe.py b/src/cpl_core/pipes/first_char_to_lower_pipe.py new file mode 100644 index 00000000..59b5c80d --- /dev/null +++ b/src/cpl_core/pipes/first_char_to_lower_pipe.py @@ -0,0 +1,20 @@ +from cpl_core.pipes.pipe_abc import PipeABC + + +class FirstCharToLowerPipe(PipeABC): + + def __init__(self): pass + + def transform(self, value: any, *args): + r"""Converts first char to lower + + Parameter + --------- + value: :class:`str` + String to convert + + Returns + ------- + String with first char as lower + """ + return f'{value[0].lower()}{value[1:]}' diff --git a/src/cpl_core/pipes/first_to_upper_pipe.py b/src/cpl_core/pipes/first_to_upper_pipe.py new file mode 100644 index 00000000..c6787b60 --- /dev/null +++ b/src/cpl_core/pipes/first_to_upper_pipe.py @@ -0,0 +1,20 @@ +from cpl_core.pipes.pipe_abc import PipeABC + + +class FirstToUpperPipe(PipeABC): + + def __init__(self): pass + + def transform(self, value: str, *args): + r"""Converts first char to upper + + Parameter + --------- + chars: :class:`str` + String to convert + + Returns + ------- + String with first char as upper + """ + return f'{value[0].upper()}{value[1:]}' diff --git a/src/cpl_core/pipes/ip_address_pipe.py b/src/cpl_core/pipes/ip_address_pipe.py new file mode 100644 index 00000000..a33852b3 --- /dev/null +++ b/src/cpl_core/pipes/ip_address_pipe.py @@ -0,0 +1,24 @@ +from cpl_core.pipes.pipe_abc import PipeABC + + +class IPAddressPipe(PipeABC): + + def __init__(self): pass + + def transform(self, value: list[int], *args): + string = "" + + if len(value) != 4: + raise Exception('Invalid IP') + + for i in range(0, len(value)): + byte = value[i] + if byte > 255: + raise Exception('Invalid IP') + + if i == len(value) - 1: + string += f'{byte}' + else: + string += f'{byte}.' + + return string diff --git a/src/cpl_core/pipe/pipe_abc.py b/src/cpl_core/pipes/pipe_abc.py similarity index 100% rename from src/cpl_core/pipe/pipe_abc.py rename to src/cpl_core/pipes/pipe_abc.py diff --git a/src/cpl_core/pipes/to_camel_case_pipe.py b/src/cpl_core/pipes/to_camel_case_pipe.py new file mode 100644 index 00000000..69769b1e --- /dev/null +++ b/src/cpl_core/pipes/to_camel_case_pipe.py @@ -0,0 +1,28 @@ +import string + +from cpl_core.pipes import PipeABC + + +class ToCamelCasePipe(PipeABC): + + def __init__(self): pass + + def transform(self, value: str, *args) -> str: + r"""Converts string to camel case + + Parameter + --------- + chars: :class:`str` + String to convert + + Returns + ------- + String converted to CamelCase + """ + converted_name = value + char_set = string.punctuation + ' ' + for char in char_set: + if char in converted_name: + converted_name = ''.join(word.title() for word in converted_name.split(char)) + + return converted_name diff --git a/src/cpl_core/pipes/to_snake_case_pipe.py b/src/cpl_core/pipes/to_snake_case_pipe.py new file mode 100644 index 00000000..9b268af7 --- /dev/null +++ b/src/cpl_core/pipes/to_snake_case_pipe.py @@ -0,0 +1,29 @@ +import re + +from cpl_core.pipes import PipeABC + + +class ToSnakeCasePipe(PipeABC): + + def __init__(self): pass + + def transform(self, value: str, *args) -> str: + r"""Converts string to snake case + + Parameter + --------- + chars: :class:`str` + String to convert + + Returns + ------- + String converted to snake_case + """ + # convert to train-case to CamelCase + if '-' in value: + value = ''.join(word.title() for word in value.split('-')) + + pattern1 = re.compile(r'(.)([A-Z][a-z]+)') + pattern2 = re.compile(r'([a-z0-9])([A-Z])') + file_name = re.sub(pattern1, r'\1_\2', value) + return re.sub(pattern2, r'\1_\2', file_name).lower() diff --git a/src/cpl_core/time/__init__.py b/src/cpl_core/time/__init__.py index b4712aac..206931b3 100644 --- a/src/cpl_core/time/__init__.py +++ b/src/cpl_core/time/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.time' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' 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='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/cpl_core/utils/__init__.py b/src/cpl_core/utils/__init__.py index 934ebe3f..2da0bcb3 100644 --- a/src/cpl_core/utils/__init__.py +++ b/src/cpl_core/utils/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_core.utils' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' -__version__ = '2022.6.3' +__version__ = '2022.6.7.dev1' 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='2022', minor='6', micro='3') +version_info = VersionInfo(major='2022', minor='6', micro='7.dev1') diff --git a/src/tests/custom/general/src/general/parameter_startup.py b/src/tests/custom/general/src/general/parameter_startup.py index 449956f0..81380936 100644 --- a/src/tests/custom/general/src/general/parameter_startup.py +++ b/src/tests/custom/general/src/general/parameter_startup.py @@ -1,6 +1,5 @@ from cpl_core.application import StartupExtensionABC -from cpl_core.configuration import ConfigurationABC -from cpl_core.configuration.argument_type_enum import ArgumentTypeEnum +from cpl_core.configuration import ConfigurationABC, ArgumentTypeEnum from cpl_core.dependency_injection import ServiceCollectionABC from cpl_core.environment import ApplicationEnvironmentABC from arguments.generate_argument import GenerateArgument diff --git a/src/tests/custom/general/src/general/startup.py b/src/tests/custom/general/src/general/startup.py index 34337e03..941dc1ef 100644 --- a/src/tests/custom/general/src/general/startup.py +++ b/src/tests/custom/general/src/general/startup.py @@ -1,12 +1,10 @@ -from cpl_core.application.startup_abc import StartupABC -from cpl_core.configuration.configuration_abc import ConfigurationABC -from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC -from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC -from cpl_core.environment.application_environment_abc import ApplicationEnvironmentABC -from cpl_core.logging.logger_service import Logger -from cpl_core.logging.logger_abc import LoggerABC -from cpl_core.mailing.email_client_service import EMailClient -from cpl_core.mailing.email_client_abc import EMailClientABC +from cpl_core.application import StartupABC +from cpl_core.configuration import ConfigurationABC +from cpl_core.dependency_injection import ServiceCollectionABC, ServiceProviderABC +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_core.logging import Logger, LoggerABC +from cpl_core.mailing import EMailClient, EMailClientABC +from cpl_core.pipes import IPAddressPipe from test_service import TestService @@ -27,6 +25,7 @@ class Startup(StartupABC): def configure_services(self, services: ServiceCollectionABC, env: ApplicationEnvironmentABC) -> ServiceProviderABC: services.add_singleton(LoggerABC, Logger) services.add_singleton(EMailClientABC, EMailClient) + services.add_transient(IPAddressPipe) services.add_singleton(TestService) return services.build_service_provider() diff --git a/src/tests/custom/general/src/general/test_extension.py b/src/tests/custom/general/src/general/test_extension.py index b314c665..be766d33 100644 --- a/src/tests/custom/general/src/general/test_extension.py +++ b/src/tests/custom/general/src/general/test_extension.py @@ -1,4 +1,4 @@ -from cpl_core.application.application_extension_abc import ApplicationExtensionABC +from cpl_core.application import ApplicationExtensionABC from cpl_core.configuration import ConfigurationABC from cpl_core.console import Console from cpl_core.dependency_injection import ServiceProviderABC diff --git a/src/tests/custom/general/src/general/test_service.py b/src/tests/custom/general/src/general/test_service.py index 94600a42..3274b8dc 100644 --- a/src/tests/custom/general/src/general/test_service.py +++ b/src/tests/custom/general/src/general/test_service.py @@ -1,15 +1,16 @@ -from abc import ABC - from cpl_core.console.console import Console from cpl_core.dependency_injection import ServiceProviderABC +from cpl_core.pipes.ip_address_pipe import IPAddressPipe -class TestService(ABC): +class TestService: - def __init__(self, provider: ServiceProviderABC): - ABC.__init__(self) + 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) + ip = [192, 168, 178, 30] + Console.write_line(ip, self._ip_pipe.transform(ip))