Removed obsolete pipes
This commit is contained in:
parent
3178b59147
commit
04f610c799
@ -19,15 +19,10 @@ __version__ = "2023.4.0"
|
||||
|
||||
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="2023", minor="4", micro="0")
|
||||
|
@ -1,18 +0,0 @@
|
||||
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:]}"
|
@ -1,18 +0,0 @@
|
||||
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:]}"
|
@ -1,26 +0,0 @@
|
||||
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
|
@ -1,27 +0,0 @@
|
||||
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()
|
Loading…
Reference in New Issue
Block a user