From d1bb266d493d41f0e7d1e3d562a015f8951761ed Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 May 2022 18:43:10 +0200 Subject: [PATCH 1/4] Added Pipes --- src/cpl_cli/cpl_cli.json | 4 +-- src/cpl_core/cpl_core.json | 2 +- src/cpl_core/pipes/__init__.py | 27 +++++++++++++++++++ .../pipes/first_char_to_lower_pipe.py | 9 +++++++ src/cpl_core/pipes/pipe_abc.py | 10 +++++++ 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 src/cpl_core/pipes/__init__.py create mode 100644 src/cpl_core/pipes/first_char_to_lower_pipe.py create mode 100644 src/cpl_core/pipes/pipe_abc.py diff --git a/src/cpl_cli/cpl_cli.json b/src/cpl_cli/cpl_cli.json index 80f3612d..814c1316 100644 --- a/src/cpl_cli/cpl_cli.json +++ b/src/cpl_cli/cpl_cli.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "3" + "Micro": "7" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,7 +16,7 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=2022.6.3" + "cpl-core>=2022.6.7" ], "PythonVersion": ">=3.10", "PythonPath": {}, diff --git a/src/cpl_core/cpl_core.json b/src/cpl_core/cpl_core.json index 3e3db7a5..0d11a6ca 100644 --- a/src/cpl_core/cpl_core.json +++ b/src/cpl_core/cpl_core.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "3" + "Micro": "7" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/src/cpl_core/pipes/__init__.py b/src/cpl_core/pipes/__init__.py new file mode 100644 index 00000000..bf54bda3 --- /dev/null +++ b/src/cpl_core/pipes/__init__.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +""" +cpl-core sh-edraft Common Python library +~~~~~~~~~~~~~~~~~~~ + +sh-edraft Common Python library + +:copyright: (c) 2020 - 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'cpl_core.pipes' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' +__version__ = '2022.6.3' + +from collections import namedtuple + +# imports: +from .first_char_to_lower_pipe import FirstCharToLowerPipe +from .pipe_abc import PipeABC + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='2022', minor='6', micro='3') 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..0daa6120 --- /dev/null +++ b/src/cpl_core/pipes/first_char_to_lower_pipe.py @@ -0,0 +1,9 @@ +from cpl_core.pipes.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/pipes/pipe_abc.py b/src/cpl_core/pipes/pipe_abc.py new file mode 100644 index 00000000..2726dbc1 --- /dev/null +++ b/src/cpl_core/pipes/pipe_abc.py @@ -0,0 +1,10 @@ +from abc import ABC, abstractmethod + + +class PipeABC(ABC): + + @abstractmethod + def __init__(self): pass + + @abstractmethod + def transform(self, value: any, *args): pass From d694c408c07277553200a0fdf72bbfeb3e2fa3b2 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 May 2022 18:48:33 +0200 Subject: [PATCH 2/4] Added CLI logic to generate pipes --- .../_templates/generate/pipe_template.py | 40 +++++++++++++++++++ src/cpl_cli/command/generate_service.py | 7 ++++ src/cpl_cli/startup_argument_extension.py | 1 + src/cpl_core/{pipes => pipe}/__init__.py | 2 +- .../first_char_to_lower_pipe.py | 2 +- src/cpl_core/{pipes => pipe}/pipe_abc.py | 0 6 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/cpl_cli/_templates/generate/pipe_template.py rename src/cpl_core/{pipes => pipe}/__init__.py (95%) rename src/cpl_core/{pipes => pipe}/first_char_to_lower_pipe.py (78%) rename src/cpl_core/{pipes => pipe}/pipe_abc.py (100%) diff --git a/src/cpl_cli/_templates/generate/pipe_template.py b/src/cpl_cli/_templates/generate/pipe_template.py new file mode 100644 index 00000000..129e13ba --- /dev/null +++ b/src/cpl_cli/_templates/generate/pipe_template.py @@ -0,0 +1,40 @@ +import textwrap +from string import Template + +from cpl_core.utils.string import String +from cpl_cli._templates.template_file_abc import TemplateFileABC + + +class PipeTemplate(TemplateFileABC): + + def __init__(self, name: str, schematic: str, schematic_upper: str, path: str): + TemplateFileABC.__init__(self) + + self._name = f'{String.convert_to_snake_case(name)}_{schematic}.py' + self._class_name = f'{String.first_to_upper(name)}{schematic_upper}' + self._path = path + self._value = textwrap.dedent("""\ + from cpl_core.pipe import PipeABC + + + class $Name(PipeABC): + + def __init__(self): pass + + def transform(self, value: any, *args): + return value + """) + + @property + def name(self) -> str: + return self._name + + @property + def path(self) -> str: + return self._path + + @property + def value(self) -> str: + return Template(self._value).substitute( + Name=self._class_name + ) diff --git a/src/cpl_cli/command/generate_service.py b/src/cpl_cli/command/generate_service.py index 846e6cee..e546218e 100644 --- a/src/cpl_cli/command/generate_service.py +++ b/src/cpl_cli/command/generate_service.py @@ -2,6 +2,7 @@ import os import sys import textwrap +from cpl_cli._templates.generate.pipe_template import PipeTemplate from cpl_cli._templates.generate.validator_template import ValidatorTemplate from cpl_core.configuration.configuration_abc import ConfigurationABC from cpl_core.console.foreground_color_enum import ForegroundColorEnum @@ -40,6 +41,10 @@ class GenerateService(CommandABC): "Upper": "Enum", "Template": EnumTemplate }, + "pipe": { + "Upper": "Pipe", + "Template": PipeTemplate + }, "service": { "Upper": "Service", "Template": ServiceTemplate @@ -75,6 +80,7 @@ class GenerateService(CommandABC): abc class enum + pipe service settings thread @@ -94,6 +100,7 @@ class GenerateService(CommandABC): 'abc (a|A)', 'class (c|C)', 'enum (e|E)', + 'pipe (p|P)', 'service (s|S)', 'settings (st|ST)', 'thread (t|T)', diff --git a/src/cpl_cli/startup_argument_extension.py b/src/cpl_cli/startup_argument_extension.py index 026e572a..ab7beb4e 100644 --- a/src/cpl_cli/startup_argument_extension.py +++ b/src/cpl_cli/startup_argument_extension.py @@ -66,6 +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, '', '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/pipes/__init__.py b/src/cpl_core/pipe/__init__.py similarity index 95% rename from src/cpl_core/pipes/__init__.py rename to src/cpl_core/pipe/__init__.py index bf54bda3..b99969fa 100644 --- a/src/cpl_core/pipes/__init__.py +++ b/src/cpl_core/pipe/__init__.py @@ -11,7 +11,7 @@ sh-edraft Common Python library """ -__title__ = 'cpl_core.pipes' +__title__ = 'cpl_core.pipe' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de' diff --git a/src/cpl_core/pipes/first_char_to_lower_pipe.py b/src/cpl_core/pipe/first_char_to_lower_pipe.py similarity index 78% rename from src/cpl_core/pipes/first_char_to_lower_pipe.py rename to src/cpl_core/pipe/first_char_to_lower_pipe.py index 0daa6120..a9ad59fd 100644 --- a/src/cpl_core/pipes/first_char_to_lower_pipe.py +++ b/src/cpl_core/pipe/first_char_to_lower_pipe.py @@ -1,4 +1,4 @@ -from cpl_core.pipes.pipe_abc import PipeABC +from cpl_core.pipe.pipe_abc import PipeABC class FirstCharToLowerPipe(PipeABC): diff --git a/src/cpl_core/pipes/pipe_abc.py b/src/cpl_core/pipe/pipe_abc.py similarity index 100% rename from src/cpl_core/pipes/pipe_abc.py rename to src/cpl_core/pipe/pipe_abc.py From 824d491ebcf863baace9b130df28b768478cc640 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 May 2022 18:49:31 +0200 Subject: [PATCH 3/4] Dev build projects --- src/cpl_cli/__init__.py | 4 ++-- src/cpl_cli/_templates/__init__.py | 4 ++-- src/cpl_cli/_templates/build/__init__.py | 4 ++-- src/cpl_cli/_templates/generate/__init__.py | 4 ++-- src/cpl_cli/_templates/new/__init__.py | 4 ++-- src/cpl_cli/_templates/new/console/__init__.py | 4 ++-- src/cpl_cli/_templates/new/console/source/__init__.py | 4 ++-- src/cpl_cli/_templates/new/console/source/name/__init__.py | 4 ++-- src/cpl_cli/_templates/new/console/source/tests/__init__.py | 4 ++-- src/cpl_cli/_templates/new/library/__init__.py | 4 ++-- src/cpl_cli/_templates/new/library/source/__init__.py | 4 ++-- src/cpl_cli/_templates/new/library/source/name/__init__.py | 4 ++-- src/cpl_cli/_templates/new/library/source/tests/__init__.py | 4 ++-- src/cpl_cli/_templates/publish/__init__.py | 4 ++-- src/cpl_cli/command/__init__.py | 4 ++-- src/cpl_cli/configuration/__init__.py | 4 ++-- src/cpl_cli/cpl_cli.json | 4 ++-- src/cpl_cli/live_server/__init__.py | 4 ++-- src/cpl_cli/publish/__init__.py | 4 ++-- src/cpl_cli/source_creator/__init__.py | 4 ++-- src/cpl_cli/validators/__init__.py | 4 ++-- src/cpl_core/cpl_core.json | 2 +- 22 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/cpl_cli/__init__.py b/src/cpl_cli/__init__.py index 25bcdc48..458fec43 100644 --- a/src/cpl_cli/__init__.py +++ b/src/cpl_cli/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_cli' __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 .main import main from .startup import Startup 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_cli/_templates/__init__.py b/src/cpl_cli/_templates/__init__.py index 10cb5c3c..90dc5674 100644 --- a/src/cpl_cli/_templates/__init__.py +++ b/src/cpl_cli/_templates/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates' __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_cli/_templates/build/__init__.py b/src/cpl_cli/_templates/build/__init__.py index 1f8a42e0..766bce3c 100644 --- a/src/cpl_cli/_templates/build/__init__.py +++ b/src/cpl_cli/_templates/build/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.build' __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_cli/_templates/generate/__init__.py b/src/cpl_cli/_templates/generate/__init__.py index 825d010c..9d13f4f1 100644 --- a/src/cpl_cli/_templates/generate/__init__.py +++ b/src/cpl_cli/_templates/generate/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.generate' __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_cli/_templates/new/__init__.py b/src/cpl_cli/_templates/new/__init__.py index 389c8635..9859e001 100644 --- a/src/cpl_cli/_templates/new/__init__.py +++ b/src/cpl_cli/_templates/new/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new' __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_cli/_templates/new/console/__init__.py b/src/cpl_cli/_templates/new/console/__init__.py index e5d81735..7e6b84e1 100644 --- a/src/cpl_cli/_templates/new/console/__init__.py +++ b/src/cpl_cli/_templates/new/console/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.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 # 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_cli/_templates/new/console/source/__init__.py b/src/cpl_cli/_templates/new/console/source/__init__.py index b3ffaa60..4a388111 100644 --- a/src/cpl_cli/_templates/new/console/source/__init__.py +++ b/src/cpl_cli/_templates/new/console/source/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source' __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_cli/_templates/new/console/source/name/__init__.py b/src/cpl_cli/_templates/new/console/source/name/__init__.py index 9c3e5b97..836ce626 100644 --- a/src/cpl_cli/_templates/new/console/source/name/__init__.py +++ b/src/cpl_cli/_templates/new/console/source/name/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source.name' __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_cli/_templates/new/console/source/tests/__init__.py b/src/cpl_cli/_templates/new/console/source/tests/__init__.py index 1f397f13..8040ac3a 100644 --- a/src/cpl_cli/_templates/new/console/source/tests/__init__.py +++ b/src/cpl_cli/_templates/new/console/source/tests/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source.tests' __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_cli/_templates/new/library/__init__.py b/src/cpl_cli/_templates/new/library/__init__.py index 66570b7d..8e990a5a 100644 --- a/src/cpl_cli/_templates/new/library/__init__.py +++ b/src/cpl_cli/_templates/new/library/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library' __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_cli/_templates/new/library/source/__init__.py b/src/cpl_cli/_templates/new/library/source/__init__.py index a51a0cc9..272dc58b 100644 --- a/src/cpl_cli/_templates/new/library/source/__init__.py +++ b/src/cpl_cli/_templates/new/library/source/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source' __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_cli/_templates/new/library/source/name/__init__.py b/src/cpl_cli/_templates/new/library/source/name/__init__.py index e8896599..bd4c6376 100644 --- a/src/cpl_cli/_templates/new/library/source/name/__init__.py +++ b/src/cpl_cli/_templates/new/library/source/name/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source.name' __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_cli/_templates/new/library/source/tests/__init__.py b/src/cpl_cli/_templates/new/library/source/tests/__init__.py index 5c06dd3f..15c57e51 100644 --- a/src/cpl_cli/_templates/new/library/source/tests/__init__.py +++ b/src/cpl_cli/_templates/new/library/source/tests/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source.tests' __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_cli/_templates/publish/__init__.py b/src/cpl_cli/_templates/publish/__init__.py index 925a726a..8dc739c6 100644 --- a/src/cpl_cli/_templates/publish/__init__.py +++ b/src/cpl_cli/_templates/publish/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.publish' __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_cli/command/__init__.py b/src/cpl_cli/command/__init__.py index eaaf9a10..1bc37caa 100644 --- a/src/cpl_cli/command/__init__.py +++ b/src/cpl_cli/command/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_cli.command' __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 .publish_service import PublishService from .version_service import VersionService 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_cli/configuration/__init__.py b/src/cpl_cli/configuration/__init__.py index ad494b69..d78562ca 100644 --- a/src/cpl_cli/configuration/__init__.py +++ b/src/cpl_cli/configuration/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_cli.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 @@ -30,4 +30,4 @@ from .workspace_settings import WorkspaceSettings from .workspace_settings_name_enum import WorkspaceSettingsNameEnum 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_cli/cpl_cli.json b/src/cpl_cli/cpl_cli.json index 814c1316..fd56995c 100644 --- a/src/cpl_cli/cpl_cli.json +++ b/src/cpl_cli/cpl_cli.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "7" + "Micro": "7.dev1" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,7 +16,7 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=2022.6.7" + "cpl-core>=2022.6.7.dev1" ], "PythonVersion": ">=3.10", "PythonPath": {}, diff --git a/src/cpl_cli/live_server/__init__.py b/src/cpl_cli/live_server/__init__.py index 29527f0b..4960611e 100644 --- a/src/cpl_cli/live_server/__init__.py +++ b/src/cpl_cli/live_server/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli.live_server' __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_cli/publish/__init__.py b/src/cpl_cli/publish/__init__.py index 1acb5cf6..b386c513 100644 --- a/src/cpl_cli/publish/__init__.py +++ b/src/cpl_cli/publish/__init__.py @@ -15,7 +15,7 @@ __title__ = 'cpl_cli.publish' __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 .publisher_abc import PublisherABC from .publisher_service import PublisherService 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_cli/source_creator/__init__.py b/src/cpl_cli/source_creator/__init__.py index 6393c5bb..b2bf9556 100644 --- a/src/cpl_cli/source_creator/__init__.py +++ b/src/cpl_cli/source_creator/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli.source_creator' __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_cli/validators/__init__.py b/src/cpl_cli/validators/__init__.py index aac26b89..614bdb05 100644 --- a/src/cpl_cli/validators/__init__.py +++ b/src/cpl_cli/validators/__init__.py @@ -15,11 +15,11 @@ __title__ = 'cpl_cli.validators' __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/cpl_core.json b/src/cpl_core/cpl_core.json index 0d11a6ca..af26db2b 100644 --- a/src/cpl_core/cpl_core.json +++ b/src/cpl_core/cpl_core.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "7" + "Micro": "7.dev1" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", From cfb8838c733d3e652ee744ed64efea415d4d147a Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 May 2022 20:27:58 +0200 Subject: [PATCH 4/4] 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))