From d1bb266d493d41f0e7d1e3d562a015f8951761ed Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 22 May 2022 18:43:10 +0200 Subject: [PATCH] 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