python-base-toolkit 0.0.4__py3-none-any.whl → 0.0.6__py3-none-any.whl

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.
File without changes
@@ -0,0 +1,54 @@
1
+ import json
2
+ from enum import Enum, StrEnum
3
+ from typing import Any, TypeVar
4
+
5
+ E = TypeVar("E", bound=Enum)
6
+
7
+
8
+ class EnumMixin:
9
+ def __str__(self: E) -> str:
10
+ return str(self.value)
11
+
12
+ def __repr__(self: E) -> str:
13
+ return str(self.value)
14
+ # return f"<{self.__class__.__name__}.{self.name}: {self.value}>"
15
+
16
+ @classmethod
17
+ def to_list(cls: type[E]) -> list[Any]:
18
+ return [c.value for c in cls]
19
+
20
+ @classmethod
21
+ def to_dict(cls: type[E]) -> dict:
22
+ return {member.name: member.value for member in cls}
23
+
24
+ @classmethod
25
+ def names(cls: type[E]) -> list[str]:
26
+ return [c.name for c in cls]
27
+
28
+ @classmethod
29
+ def values(cls: type[E]) -> list[Any]:
30
+ return [c.value for c in cls]
31
+
32
+ @classmethod
33
+ def from_value(cls: type[E], value: Any) -> list[E]:
34
+ return [member for member in cls if value in member.value]
35
+
36
+ @classmethod
37
+ def has_name(cls: type[E], name: str) -> bool:
38
+ return any(member.name == name for member in cls)
39
+
40
+ @classmethod
41
+ def has_value(cls: type[E], value: Any) -> bool:
42
+ return any(member.value == value for member in cls)
43
+
44
+ @classmethod
45
+ def to_json(cls) -> str:
46
+ return json.dumps(cls.to_dict())
47
+
48
+
49
+ class BaseEnum(EnumMixin, Enum):
50
+ pass
51
+
52
+
53
+ class BaseStrEnum(EnumMixin, StrEnum):
54
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-base-toolkit
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: A Python package for managing pytest plugins.
5
5
  Author: Avi Zaguri
6
6
  License: MIT
@@ -72,6 +72,9 @@ pip install python-toolkit
72
72
  - shorten_url
73
73
  - venv_details
74
74
 
75
+ - Tasks Pack
76
+ - ...
77
+
75
78
  ---
76
79
 
77
80
  ## 🤝 Contributing
@@ -1,4 +1,6 @@
1
1
  python_base_toolkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ python_base_toolkit/base_structures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ python_base_toolkit/base_structures/base_enum.py,sha256=AzVRP8X6W1M2GoYQD3Cm9hpZE-uGnu9YoY9wX9WuFI8,1324
2
4
  python_base_toolkit/consts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
5
  python_base_toolkit/consts/operating_system.py,sha256=8cnaHVz80AecTDhQjhU-i-s88bf1UZ-u0ouxHXxDsmA,80
4
6
  python_base_toolkit/consts/units/__init__.py,sha256=1sTK8_l5mO1Osk5dD9aWkyPVXrvYjRJU1brnCmpLdRk,157
@@ -25,8 +27,8 @@ python_base_toolkit/utils/pycache.py,sha256=X-pWRjAd2xcBtMkcyCuKz34SbHWc2leBHBIj
25
27
  python_base_toolkit/utils/random_utils.py,sha256=gTH6k1MKKGNZvBTLc5H-eSmtEGvXEdLqtzXN9aHuu-A,2730
26
28
  python_base_toolkit/utils/shorten_url.py,sha256=zsyW3wloFJdVb9s3fhR-olL6ekT03FDlFm2xbFY4viw,359
27
29
  python_base_toolkit/utils/venv_details.py,sha256=d1WlZr1LuWz2SXdFP0Hqh6VHXXXSIuXB0oTmWXJrGqM,210
28
- python_base_toolkit-0.0.4.dist-info/licenses/LICENSE,sha256=cSikHY6SZFsPZSBizCDAJ0-Bjjzxt-JtX6TVbKxwimo,1067
29
- python_base_toolkit-0.0.4.dist-info/METADATA,sha256=YNk79wWpNBkvAcgGgocu9okLgkTkg-1c-Y8YsIrL4DY,2438
30
- python_base_toolkit-0.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- python_base_toolkit-0.0.4.dist-info/top_level.txt,sha256=I9kK6FGKq_6z3aGySoWamY68GRgg0xsL6sS-uyaxJ2k,20
32
- python_base_toolkit-0.0.4.dist-info/RECORD,,
30
+ python_base_toolkit-0.0.6.dist-info/licenses/LICENSE,sha256=cSikHY6SZFsPZSBizCDAJ0-Bjjzxt-JtX6TVbKxwimo,1067
31
+ python_base_toolkit-0.0.6.dist-info/METADATA,sha256=pBwnzOQG54L_yqC2x6XcwK-v4zQhS7BtjFGIknYP30A,2460
32
+ python_base_toolkit-0.0.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ python_base_toolkit-0.0.6.dist-info/top_level.txt,sha256=I9kK6FGKq_6z3aGySoWamY68GRgg0xsL6sS-uyaxJ2k,20
34
+ python_base_toolkit-0.0.6.dist-info/RECORD,,