GeneralManager 0.1.1__py3-none-any.whl → 0.1.2__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.
- general_manager/auxiliary/noneToZero.py +3 -3
- general_manager/interface/databaseInterface.py +2 -2
- general_manager/manager/input.py +29 -4
- {generalmanager-0.1.1.dist-info → generalmanager-0.1.2.dist-info}/METADATA +1 -1
- {generalmanager-0.1.1.dist-info → generalmanager-0.1.2.dist-info}/RECORD +8 -8
- {generalmanager-0.1.1.dist-info → generalmanager-0.1.2.dist-info}/WHEEL +0 -0
- {generalmanager-0.1.1.dist-info → generalmanager-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {generalmanager-0.1.1.dist-info → generalmanager-0.1.2.dist-info}/top_level.txt +0 -0
@@ -1,12 +1,12 @@
|
|
1
1
|
from typing import Optional, TypeVar, Literal
|
2
2
|
from general_manager.measurement import Measurement
|
3
3
|
|
4
|
-
|
4
|
+
NUMBERVALUE = TypeVar("NUMBERVALUE", int, float, Measurement)
|
5
5
|
|
6
6
|
|
7
7
|
def noneToZero(
|
8
|
-
value: Optional[
|
9
|
-
) ->
|
8
|
+
value: Optional[NUMBERVALUE],
|
9
|
+
) -> NUMBERVALUE | Literal[0]:
|
10
10
|
if value is None:
|
11
11
|
return 0
|
12
12
|
return value
|
@@ -654,7 +654,7 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
654
654
|
kwarg_filter[key].append(value)
|
655
655
|
return kwarg_filter
|
656
656
|
|
657
|
-
def filter(self, **kwargs: Any) -> DatabaseBucket:
|
657
|
+
def filter(self, **kwargs: Any) -> DatabaseBucket[GeneralManagerType]:
|
658
658
|
merged_filter = self.__mergeFilterDefinitions(self.filters, **kwargs)
|
659
659
|
return self.__class__(
|
660
660
|
self._data.filter(**kwargs),
|
@@ -663,7 +663,7 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
663
663
|
self.excludes,
|
664
664
|
)
|
665
665
|
|
666
|
-
def exclude(self, **kwargs: Any) -> DatabaseBucket:
|
666
|
+
def exclude(self, **kwargs: Any) -> DatabaseBucket[GeneralManagerType]:
|
667
667
|
merged_exclude = self.__mergeFilterDefinitions(self.excludes, **kwargs)
|
668
668
|
return self.__class__(
|
669
669
|
self._data.exclude(**kwargs),
|
general_manager/manager/input.py
CHANGED
@@ -17,6 +17,14 @@ class Input(Generic[INPUT_TYPE]):
|
|
17
17
|
possible_values: Optional[Callable | Iterable] = None,
|
18
18
|
depends_on: Optional[List[str]] = None,
|
19
19
|
):
|
20
|
+
"""
|
21
|
+
Initializes an Input instance with type information, possible values, and dependencies.
|
22
|
+
|
23
|
+
Args:
|
24
|
+
type: The expected type for the input value.
|
25
|
+
possible_values: An optional iterable or callable that defines allowed values.
|
26
|
+
depends_on: An optional list of dependency names. If not provided and possible_values is callable, dependencies are inferred from its parameters.
|
27
|
+
"""
|
20
28
|
self.type = type
|
21
29
|
self.possible_values = possible_values
|
22
30
|
self.is_manager = issubclass(type, GeneralManager)
|
@@ -33,16 +41,33 @@ class Input(Generic[INPUT_TYPE]):
|
|
33
41
|
self.depends_on = []
|
34
42
|
|
35
43
|
def cast(self, value: Any) -> Any:
|
44
|
+
"""
|
45
|
+
Casts the input value to the type specified by this Input instance.
|
46
|
+
|
47
|
+
Handles special cases for date, datetime, GeneralManager subclasses, and Measurement types.
|
48
|
+
If the value is already of the target type, it is returned unchanged. Otherwise, attempts to
|
49
|
+
convert or construct the value as appropriate for the target type.
|
50
|
+
|
51
|
+
Args:
|
52
|
+
value: The value to be cast or converted.
|
53
|
+
|
54
|
+
Returns:
|
55
|
+
The value converted to the target type, or an instance of the target type.
|
56
|
+
"""
|
57
|
+
if self.type == date:
|
58
|
+
if isinstance(value, datetime) and type(value) is not date:
|
59
|
+
return value.date()
|
60
|
+
return date.fromisoformat(value)
|
61
|
+
if self.type == datetime:
|
62
|
+
if isinstance(value, date):
|
63
|
+
return datetime.combine(value, datetime.min.time())
|
64
|
+
return datetime.fromisoformat(value)
|
36
65
|
if isinstance(value, self.type):
|
37
66
|
return value
|
38
67
|
if issubclass(self.type, GeneralManager):
|
39
68
|
if isinstance(value, dict):
|
40
69
|
return self.type(**value) # type: ignore
|
41
70
|
return self.type(id=value) # type: ignore
|
42
|
-
if self.type == date:
|
43
|
-
return date.fromisoformat(value)
|
44
|
-
if self.type == datetime:
|
45
|
-
return datetime.fromisoformat(value)
|
46
71
|
if self.type == Measurement and isinstance(value, str):
|
47
72
|
return Measurement.from_string(value)
|
48
73
|
return self.type(value)
|
@@ -6,7 +6,7 @@ general_manager/api/property.py,sha256=oc93p1P8dcIvrNorRuqD1EJVsd6eYttYhZuAS0s28
|
|
6
6
|
general_manager/auxiliary/__init__.py,sha256=4IwKJzsNxGduF-Ej0u1BNHVaMhkql8PjHbVtx9DOTSY,76
|
7
7
|
general_manager/auxiliary/argsToKwargs.py,sha256=kmp1xonpQp4X_y8ZJG6c5uOW7zQwo0HtPqsHWVzXRSM,921
|
8
8
|
general_manager/auxiliary/filterParser.py,sha256=exmRGVwvdMPgN-65MLwAV2q6L23bI4gTWb6lWXO4ZuU,3108
|
9
|
-
general_manager/auxiliary/noneToZero.py,sha256=
|
9
|
+
general_manager/auxiliary/noneToZero.py,sha256=ovopSddMlTw84GIFWRd5s91_CFahPyL-t974w78Jb7g,300
|
10
10
|
general_manager/cache/cacheDecorator.py,sha256=RmUDyJfkouO2-R2KZZJF1n8RCB0FjVa2OoTeLQ0vUyg,2934
|
11
11
|
general_manager/cache/cacheTracker.py,sha256=vUQCarqABIW_O02hbKeRo0thurmPD0TfrOlIUh7kneI,1045
|
12
12
|
general_manager/cache/dependencyIndex.py,sha256=KUDroajKrWfJv0PO2EQVNTrYq7XxrpBT4MGKBgPwMwo,10676
|
@@ -18,11 +18,11 @@ general_manager/factory/lazy_methods.py,sha256=UJC50a4Gbe4T5IQPh7ucyQqpaS2x4zhQz
|
|
18
18
|
general_manager/interface/__init__.py,sha256=6x5adQLefTugvrJeyPcAxstyqgLAYeaJ1EPdAbac9pE,213
|
19
19
|
general_manager/interface/baseInterface.py,sha256=mvSKUlA-0fazNnaIXGBwkiZxmX8DM_sOn-SaAIpaW8I,10273
|
20
20
|
general_manager/interface/calculationInterface.py,sha256=GzSNXjU6Z7bFz60gHyMKkI5xNUDIPuniV8wbyVtQT50,14250
|
21
|
-
general_manager/interface/databaseInterface.py,sha256=
|
21
|
+
general_manager/interface/databaseInterface.py,sha256=VR3V8WTE6XEeM84bv09h2__XMnTWp92u8CA8WRlevWc,27377
|
22
22
|
general_manager/manager/__init__.py,sha256=l3RYp62aEhj3Y975_XUTIzo35LUnkTJHkb_hgChnXXI,111
|
23
23
|
general_manager/manager/generalManager.py,sha256=xt7tvwTaPGhh7Z8VhbdMJuScsl78B9QDVQoMWv4amuo,5158
|
24
24
|
general_manager/manager/groupManager.py,sha256=O4FABqbm7KlZw6t36Ot3HU1FsBYN0h6Zhmk7ktN8a-Y,10087
|
25
|
-
general_manager/manager/input.py,sha256=
|
25
|
+
general_manager/manager/input.py,sha256=iKawV3P1QICz-0AQUF00OvH7LZYxussg3svpvCUl8hE,2977
|
26
26
|
general_manager/manager/meta.py,sha256=5wHrCVnua5c38vpVZSCesrNvgydQDH8h6pxW6_QgCDg,3107
|
27
27
|
general_manager/measurement/__init__.py,sha256=X97meFujBldE5v0WMF7SmKeGpC5R0JTczfLo_Lq1Xek,84
|
28
28
|
general_manager/measurement/measurement.py,sha256=hTISANW7nAN2voakq9f-naJxa1MUcxWLDrcDW1Rdn3s,9340
|
@@ -36,8 +36,8 @@ general_manager/permission/permissionDataManager.py,sha256=Ji7fsnuaKTa6M8yzCGyzr
|
|
36
36
|
general_manager/rule/__init__.py,sha256=4Har5cfPD1fmOsilTDod-ZUz3Com-tkl58jz7yY4fD0,23
|
37
37
|
general_manager/rule/handler.py,sha256=O3BZbTnUE9o3LTSWpoq6hgm3tKy1sEBjRcDrRaA54Gw,3936
|
38
38
|
general_manager/rule/rule.py,sha256=tu3pNe_avs6ayI16KYeaQX85o2lXcPip_LN9CJEhr8Y,10708
|
39
|
-
generalmanager-0.1.
|
40
|
-
generalmanager-0.1.
|
41
|
-
generalmanager-0.1.
|
42
|
-
generalmanager-0.1.
|
43
|
-
generalmanager-0.1.
|
39
|
+
generalmanager-0.1.2.dist-info/licenses/LICENSE,sha256=YGFm0ieb4KpkMRRt2qnWue6uFh0cUMtobwEBkHwajhc,1450
|
40
|
+
generalmanager-0.1.2.dist-info/METADATA,sha256=gfnRxKVbWKkOoCdnaR4cTvT7kXEaW6c5_kFTTEkFqVU,8188
|
41
|
+
generalmanager-0.1.2.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
42
|
+
generalmanager-0.1.2.dist-info/top_level.txt,sha256=sTDtExP9ga-YP3h3h42yivUY-A2Q23C2nw6LNKOho4I,16
|
43
|
+
generalmanager-0.1.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|