python-base-toolkit 1.0.1__tar.gz → 1.0.2__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.
- {python_base_toolkit-1.0.1/python_base_toolkit.egg-info → python_base_toolkit-1.0.2}/PKG-INFO +1 -1
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/pyproject.toml +1 -1
- python_base_toolkit-1.0.2/python_base_toolkit/base_structures/base_pydantic_model.py +38 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2/python_base_toolkit.egg-info}/PKG-INFO +1 -1
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit.egg-info/SOURCES.txt +1 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/LICENSE +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/MANIFEST.in +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/README.md +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/Taskfile.yml +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/__init__.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/base_structures/__init__.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/base_structures/base_enum.py +4 -4
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/default.yml +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/dependencies.yml +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/deploy.yml +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/docker.yml +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/includes.yml +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/install.yml +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/lint.yml +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/vars.yml +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/consts/__init__.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/consts/operating_system.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/consts/units/__init__.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/consts/units/binary_units.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/consts/units/time_units.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/decorators/__init__.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/decorators/telemetry.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/decorators/timer.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/instances/__init__.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/instances/instance_manager.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/scripts/__init__.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/scripts/remove_build_files.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/__init__.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/data_serialization.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/date_time.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/execute.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/file_utils.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/generate_id.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/logo.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/network.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/path_utils.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/pretty_print.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/pycache.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/random_utils.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/shorten_url.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/venv_details.py +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit.egg-info/dependency_links.txt +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit.egg-info/not-zip-safe +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit.egg-info/requires.txt +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit.egg-info/top_level.txt +0 -0
- {python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/setup.cfg +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import Any, TypeVar
|
|
2
|
+
from pydantic import BaseModel
|
|
3
|
+
|
|
4
|
+
T = TypeVar("T", bound="PydanticMixin")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class BasePydanticModel(BaseModel):
|
|
8
|
+
"""Mixin to add Enum-like utility methods to Pydantic BaseModels."""
|
|
9
|
+
|
|
10
|
+
def __str__(self) -> str:
|
|
11
|
+
return f"{self.__class__.__name__}({self.model_dump()})"
|
|
12
|
+
|
|
13
|
+
def to_dict(self, **kwargs) -> dict[str, Any]:
|
|
14
|
+
"""Wrapper for model_dump."""
|
|
15
|
+
return self.model_dump(**kwargs)
|
|
16
|
+
|
|
17
|
+
def to_json(self, **kwargs) -> str:
|
|
18
|
+
"""Wrapper for model_dump_json."""
|
|
19
|
+
return self.model_dump_json(**kwargs)
|
|
20
|
+
|
|
21
|
+
def values(self) -> list[Any]:
|
|
22
|
+
"""Returns a list of the current instance's field values."""
|
|
23
|
+
return list(self.model_dump().values())
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def field_names(cls) -> list[str]:
|
|
27
|
+
"""Returns a list of all field names defined in the model."""
|
|
28
|
+
return list(cls.model_fields.keys())
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def has_field(cls, name: str) -> bool:
|
|
32
|
+
"""Checks if a field name exists in the model definition."""
|
|
33
|
+
return name in cls.model_fields
|
|
34
|
+
|
|
35
|
+
@classmethod
|
|
36
|
+
def to_schema_dict(cls) -> dict[str, Any]:
|
|
37
|
+
"""Returns the JSON schema of the model as a dictionary."""
|
|
38
|
+
return cls.model_json_schema()
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit.egg-info/SOURCES.txt
RENAMED
|
@@ -12,6 +12,7 @@ python_base_toolkit.egg-info/requires.txt
|
|
|
12
12
|
python_base_toolkit.egg-info/top_level.txt
|
|
13
13
|
python_base_toolkit/base_structures/__init__.py
|
|
14
14
|
python_base_toolkit/base_structures/base_enum.py
|
|
15
|
+
python_base_toolkit/base_structures/base_pydantic_model.py
|
|
15
16
|
python_base_toolkit/ci/task_files/default.yml
|
|
16
17
|
python_base_toolkit/ci/task_files/dependencies.yml
|
|
17
18
|
python_base_toolkit/ci/task_files/deploy.yml
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -21,6 +21,10 @@ class EnumMixin:
|
|
|
21
21
|
def to_dict(cls: type[E]) -> dict:
|
|
22
22
|
return {member.name: member.value for member in cls}
|
|
23
23
|
|
|
24
|
+
@classmethod
|
|
25
|
+
def to_json(cls) -> str:
|
|
26
|
+
return json.dumps(cls.to_dict())
|
|
27
|
+
|
|
24
28
|
@classmethod
|
|
25
29
|
def names(cls: type[E]) -> list[str]:
|
|
26
30
|
return [c.name for c in cls]
|
|
@@ -41,10 +45,6 @@ class EnumMixin:
|
|
|
41
45
|
def has_value(cls: type[E], value: Any) -> bool:
|
|
42
46
|
return any(member.value == value for member in cls)
|
|
43
47
|
|
|
44
|
-
@classmethod
|
|
45
|
-
def to_json(cls) -> str:
|
|
46
|
-
return json.dumps(cls.to_dict())
|
|
47
|
-
|
|
48
48
|
|
|
49
49
|
class BaseEnum(EnumMixin, Enum):
|
|
50
50
|
pass
|
|
File without changes
|
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/deploy.yml
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/docker.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/lint.yml
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/ci/task_files/vars.yml
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/consts/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/consts/units/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/decorators/__init__.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/decorators/telemetry.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/decorators/timer.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/instances/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/scripts/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/date_time.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/execute.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/file_utils.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/generate_id.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/network.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/path_utils.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/pretty_print.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/pycache.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/random_utils.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/shorten_url.py
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit/utils/venv_details.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit.egg-info/requires.txt
RENAMED
|
File without changes
|
{python_base_toolkit-1.0.1 → python_base_toolkit-1.0.2}/python_base_toolkit.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|