csrd-utils 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- csrd_utils-0.1.1/PKG-INFO +13 -0
- csrd_utils-0.1.1/README.md +0 -0
- csrd_utils-0.1.1/pyproject.toml +18 -0
- csrd_utils-0.1.1/src/csrd_utils/__init__.py +1 -0
- csrd_utils-0.1.1/src/csrd_utils/config/__init__.py +3 -0
- csrd_utils-0.1.1/src/csrd_utils/config/_config.py +20 -0
- csrd_utils-0.1.1/src/csrd_utils/string_utils.py +44 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: csrd-utils
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary:
|
|
5
|
+
Author: aaron
|
|
6
|
+
Author-email: aaron@frostmn.com
|
|
7
|
+
Requires-Python: >=3.12,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Requires-Dist: pre-commit (>=3.8.0,<4.0.0)
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "csrd-utils"
|
|
3
|
+
version = "0.1.1"
|
|
4
|
+
description = ""
|
|
5
|
+
authors = ["aaron <aaron@frostmn.com>"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
|
|
8
|
+
[tool.poetry.dependencies]
|
|
9
|
+
python = "^3.12"
|
|
10
|
+
pre-commit = "^3.8.0"
|
|
11
|
+
|
|
12
|
+
[[tool.poetry.source]]
|
|
13
|
+
name = "PyPI"
|
|
14
|
+
priority = "primary"
|
|
15
|
+
|
|
16
|
+
[build-system]
|
|
17
|
+
requires = ["poetry-core"]
|
|
18
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import *
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class _Config(ABC):
|
|
5
|
+
_template: dict = None
|
|
6
|
+
|
|
7
|
+
def _init_template(self) -> dict:
|
|
8
|
+
if self._template is None:
|
|
9
|
+
self._template = self._init_data()
|
|
10
|
+
return self._template
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def _init_data(data: dict = None) -> dict:
|
|
14
|
+
if data is None:
|
|
15
|
+
data = {}
|
|
16
|
+
return data
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@abstractmethod
|
|
20
|
+
def compile(self): ...
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def to_title(snake: str):
|
|
5
|
+
"""Convert a snake_case string to `Title Case`.
|
|
6
|
+
|
|
7
|
+
Args:
|
|
8
|
+
snake: The string to convert.
|
|
9
|
+
|
|
10
|
+
Returns:
|
|
11
|
+
The `Title Case` string.
|
|
12
|
+
"""
|
|
13
|
+
return snake.title().replace('_', ' ')
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def to_pascal(snake: str) -> str:
|
|
17
|
+
"""Convert a snake_case string to PascalCase.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
snake: The string to convert.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
The PascalCase string.
|
|
24
|
+
"""
|
|
25
|
+
camel = snake.title()
|
|
26
|
+
return re.sub('([0-9A-Za-z])_(?=[0-9A-Z])', lambda m: m.group(1), camel)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def to_camel(snake: str) -> str:
|
|
30
|
+
"""Convert a snake_case string to camelCase.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
snake: The string to convert.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
The converted camelCase string.
|
|
37
|
+
"""
|
|
38
|
+
# If the string is already in camelCase and does not contain a digit followed
|
|
39
|
+
# by a lowercase letter, return it as it is
|
|
40
|
+
if re.match('^[a-z]+[A-Za-z0-9]*$', snake) and not re.search(r'\d[a-z]', snake):
|
|
41
|
+
return snake
|
|
42
|
+
|
|
43
|
+
camel = to_pascal(snake)
|
|
44
|
+
return re.sub('(^_*[A-Z])', lambda m: m.group(1).lower(), camel)
|