GeneralManager 0.4.5__py3-none-any.whl → 0.4.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.
- general_manager/factory/autoFactory.py +224 -0
- general_manager/factory/factories.py +4 -146
- general_manager/interface/databaseInterface.py +8 -12
- general_manager/manager/generalManager.py +22 -6
- {generalmanager-0.4.5.dist-info → generalmanager-0.4.6.dist-info}/METADATA +1 -1
- {generalmanager-0.4.5.dist-info → generalmanager-0.4.6.dist-info}/RECORD +9 -8
- {generalmanager-0.4.5.dist-info → generalmanager-0.4.6.dist-info}/WHEEL +0 -0
- {generalmanager-0.4.5.dist-info → generalmanager-0.4.6.dist-info}/licenses/LICENSE +0 -0
- {generalmanager-0.4.5.dist-info → generalmanager-0.4.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
from typing import TYPE_CHECKING, Type, Callable, Union, Any, TypeVar, Literal
|
3
|
+
from django.db import models
|
4
|
+
from factory.django import DjangoModelFactory
|
5
|
+
from general_manager.factory.factories import getFieldValue, getManyToManyFieldValue
|
6
|
+
|
7
|
+
|
8
|
+
if TYPE_CHECKING:
|
9
|
+
from general_manager.interface.databaseInterface import (
|
10
|
+
DBBasedInterface,
|
11
|
+
)
|
12
|
+
|
13
|
+
modelsModel = TypeVar("modelsModel", bound=models.Model)
|
14
|
+
|
15
|
+
|
16
|
+
class AutoFactory(DjangoModelFactory[modelsModel]):
|
17
|
+
"""
|
18
|
+
A factory class that automatically generates values for model fields,
|
19
|
+
including handling of unique fields and constraints.
|
20
|
+
"""
|
21
|
+
|
22
|
+
interface: Type[DBBasedInterface]
|
23
|
+
_adjustmentMethod: (
|
24
|
+
Callable[..., Union[dict[str, Any], list[dict[str, Any]]]] | None
|
25
|
+
) = None
|
26
|
+
|
27
|
+
@classmethod
|
28
|
+
def _generate(
|
29
|
+
cls, strategy: Literal["build", "create"], params: dict[str, Any]
|
30
|
+
) -> models.Model | list[models.Model]:
|
31
|
+
"""
|
32
|
+
Generates and populates a Django model instance or list of instances with automatic field value assignment.
|
33
|
+
|
34
|
+
Automatically assigns values to unset model fields, including handling custom and special fields, and processes many-to-many relationships after instance creation or building. Raises a ValueError if the model is not a subclass of Django's Model.
|
35
|
+
|
36
|
+
Args:
|
37
|
+
strategy: Specifies whether to build (unsaved) or create (saved) the instance(s).
|
38
|
+
params: Field values to use for instance generation; missing fields are auto-filled.
|
39
|
+
|
40
|
+
Returns:
|
41
|
+
A single model instance or a list of model instances, depending on the input parameters and strategy.
|
42
|
+
"""
|
43
|
+
cls._original_params = params
|
44
|
+
model = cls._meta.model
|
45
|
+
if not issubclass(model, models.Model):
|
46
|
+
raise ValueError("Model must be a type")
|
47
|
+
field_name_list, to_ignore_list = cls.interface.handleCustomFields(model)
|
48
|
+
|
49
|
+
fields = [
|
50
|
+
field
|
51
|
+
for field in model._meta.get_fields()
|
52
|
+
if field.name not in to_ignore_list
|
53
|
+
]
|
54
|
+
special_fields: list[models.Field[Any, Any]] = [
|
55
|
+
getattr(model, field_name) for field_name in field_name_list
|
56
|
+
]
|
57
|
+
pre_declarations = getattr(cls._meta, "pre_declarations", [])
|
58
|
+
post_declarations = getattr(cls._meta, "post_declarations", [])
|
59
|
+
declared_fields: set[str] = set(pre_declarations) | set(post_declarations)
|
60
|
+
|
61
|
+
field_list: list[models.Field[Any, Any] | models.ForeignObjectRel] = [
|
62
|
+
*fields,
|
63
|
+
*special_fields,
|
64
|
+
]
|
65
|
+
|
66
|
+
for field in field_list:
|
67
|
+
if field.name in [*params, *declared_fields]:
|
68
|
+
continue # Skip fields that are already set
|
69
|
+
if isinstance(field, models.AutoField) or field.auto_created:
|
70
|
+
continue # Skip auto fields
|
71
|
+
params[field.name] = getFieldValue(field)
|
72
|
+
|
73
|
+
obj: list[models.Model] | models.Model = super()._generate(strategy, params)
|
74
|
+
if isinstance(obj, list):
|
75
|
+
for item in obj: # type: ignore
|
76
|
+
if not isinstance(item, models.Model):
|
77
|
+
raise ValueError("Model must be a type")
|
78
|
+
cls._handleManyToManyFieldsAfterCreation(item, params)
|
79
|
+
else:
|
80
|
+
cls._handleManyToManyFieldsAfterCreation(obj, params)
|
81
|
+
return obj
|
82
|
+
|
83
|
+
@classmethod
|
84
|
+
def _handleManyToManyFieldsAfterCreation(
|
85
|
+
cls, obj: models.Model, attrs: dict[str, Any]
|
86
|
+
) -> None:
|
87
|
+
"""
|
88
|
+
Sets many-to-many field values on a Django model instance after creation.
|
89
|
+
|
90
|
+
For each many-to-many field, assigns related objects from the provided attributes if available; otherwise, generates values using `getManyToManyFieldValue`. The related objects are set using the Django ORM's `set` method.
|
91
|
+
"""
|
92
|
+
for field in obj._meta.many_to_many:
|
93
|
+
if field.name in attrs:
|
94
|
+
m2m_values = attrs[field.name]
|
95
|
+
else:
|
96
|
+
m2m_values = getManyToManyFieldValue(field)
|
97
|
+
if m2m_values:
|
98
|
+
getattr(obj, field.name).set(m2m_values)
|
99
|
+
|
100
|
+
@classmethod
|
101
|
+
def _adjust_kwargs(cls, **kwargs: dict[str, Any]) -> dict[str, Any]:
|
102
|
+
# Remove ManyToMany fields from kwargs before object creation
|
103
|
+
"""
|
104
|
+
Removes many-to-many field entries from keyword arguments before model instance creation.
|
105
|
+
|
106
|
+
Returns:
|
107
|
+
The keyword arguments dictionary with many-to-many fields removed.
|
108
|
+
"""
|
109
|
+
model: Type[models.Model] = cls._meta.model
|
110
|
+
m2m_fields = {field.name for field in model._meta.many_to_many}
|
111
|
+
for field_name in m2m_fields:
|
112
|
+
kwargs.pop(field_name, None)
|
113
|
+
return kwargs
|
114
|
+
|
115
|
+
@classmethod
|
116
|
+
def _create(
|
117
|
+
cls, model_class: Type[models.Model], *args: list[Any], **kwargs: dict[str, Any]
|
118
|
+
) -> models.Model | list[models.Model]:
|
119
|
+
"""
|
120
|
+
Creates and saves a Django model instance or instances, applying optional adjustment logic.
|
121
|
+
|
122
|
+
If an adjustment method is defined, it is used to generate or modify field values before creation. Otherwise, the model is instantiated and saved with the provided attributes.
|
123
|
+
|
124
|
+
Args:
|
125
|
+
model_class: The Django model class to instantiate.
|
126
|
+
|
127
|
+
Returns:
|
128
|
+
A saved model instance or a list of instances.
|
129
|
+
"""
|
130
|
+
kwargs = cls._adjust_kwargs(**kwargs)
|
131
|
+
if cls._adjustmentMethod is not None:
|
132
|
+
return cls.__createWithGenerateFunc(use_creation_method=True, params=kwargs)
|
133
|
+
return cls._modelCreation(model_class, **kwargs)
|
134
|
+
|
135
|
+
@classmethod
|
136
|
+
def _build(
|
137
|
+
cls, model_class: Type[models.Model], *args: list[Any], **kwargs: dict[str, Any]
|
138
|
+
) -> models.Model | list[models.Model]:
|
139
|
+
"""
|
140
|
+
Constructs an unsaved instance or list of instances of the given Django model class.
|
141
|
+
|
142
|
+
If an adjustment method is defined, it is used to generate or modify field values before building the instance(s). Many-to-many fields are removed from the keyword arguments prior to instantiation.
|
143
|
+
"""
|
144
|
+
kwargs = cls._adjust_kwargs(**kwargs)
|
145
|
+
if cls._adjustmentMethod is not None:
|
146
|
+
return cls.__createWithGenerateFunc(
|
147
|
+
use_creation_method=False, params=kwargs
|
148
|
+
)
|
149
|
+
return cls._modelBuilding(model_class, **kwargs)
|
150
|
+
|
151
|
+
@classmethod
|
152
|
+
def _modelCreation(
|
153
|
+
cls, model_class: Type[models.Model], **kwargs: dict[str, Any]
|
154
|
+
) -> models.Model:
|
155
|
+
"""
|
156
|
+
Creates and saves a Django model instance with the provided field values.
|
157
|
+
|
158
|
+
Initializes the model, assigns attributes from keyword arguments, validates the instance using `full_clean()`, and saves it to the database.
|
159
|
+
|
160
|
+
Returns:
|
161
|
+
The saved Django model instance.
|
162
|
+
"""
|
163
|
+
obj = model_class()
|
164
|
+
for field, value in kwargs.items():
|
165
|
+
setattr(obj, field, value)
|
166
|
+
obj.full_clean()
|
167
|
+
obj.save()
|
168
|
+
return obj
|
169
|
+
|
170
|
+
@classmethod
|
171
|
+
def _modelBuilding(
|
172
|
+
cls, model_class: Type[models.Model], **kwargs: dict[str, Any]
|
173
|
+
) -> models.Model:
|
174
|
+
"""
|
175
|
+
Constructs an unsaved instance of the specified Django model with provided field values.
|
176
|
+
|
177
|
+
Args:
|
178
|
+
model_class: The Django model class to instantiate.
|
179
|
+
**kwargs: Field values to set on the model instance.
|
180
|
+
|
181
|
+
Returns:
|
182
|
+
An unsaved Django model instance with attributes set from kwargs.
|
183
|
+
"""
|
184
|
+
obj = model_class()
|
185
|
+
for field, value in kwargs.items():
|
186
|
+
setattr(obj, field, value)
|
187
|
+
return obj
|
188
|
+
|
189
|
+
@classmethod
|
190
|
+
def __createWithGenerateFunc(
|
191
|
+
cls, use_creation_method: bool, params: dict[str, Any]
|
192
|
+
) -> models.Model | list[models.Model]:
|
193
|
+
"""
|
194
|
+
Generates one or more model instances using the adjustment method for field values.
|
195
|
+
|
196
|
+
If the adjustment method returns a single dictionary, creates or builds a single model instance.
|
197
|
+
If it returns a list of dictionaries, creates or builds multiple instances accordingly.
|
198
|
+
|
199
|
+
Args:
|
200
|
+
use_creation_method: If True, saves instances to the database; otherwise, builds unsaved instances.
|
201
|
+
params: Parameters to pass to the adjustment method for generating field values.
|
202
|
+
|
203
|
+
Returns:
|
204
|
+
A single model instance or a list of model instances, depending on the adjustment method's output.
|
205
|
+
|
206
|
+
Raises:
|
207
|
+
ValueError: If the adjustment method is not defined.
|
208
|
+
"""
|
209
|
+
model_cls = cls._meta.model
|
210
|
+
if cls._adjustmentMethod is None:
|
211
|
+
raise ValueError("generate_func is not defined")
|
212
|
+
records = cls._adjustmentMethod(**params)
|
213
|
+
if isinstance(records, dict):
|
214
|
+
if use_creation_method:
|
215
|
+
return cls._modelCreation(model_cls, **records)
|
216
|
+
return cls._modelBuilding(model_cls, **records)
|
217
|
+
|
218
|
+
created_objects: list[models.Model] = []
|
219
|
+
for record in records:
|
220
|
+
if use_creation_method:
|
221
|
+
created_objects.append(cls._modelCreation(model_cls, **record))
|
222
|
+
else:
|
223
|
+
created_objects.append(cls._modelBuilding(model_cls, **record))
|
224
|
+
return created_objects
|
@@ -1,164 +1,22 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
-
from typing import
|
2
|
+
from typing import Any, cast
|
3
3
|
from factory.declarations import LazyFunction
|
4
4
|
from factory.faker import Faker
|
5
5
|
import exrex # type: ignore
|
6
6
|
from django.db import models
|
7
7
|
from django.core.validators import RegexValidator
|
8
|
-
from factory.django import DjangoModelFactory
|
9
8
|
import random
|
10
9
|
from decimal import Decimal
|
11
10
|
from general_manager.measurement.measurement import Measurement
|
12
11
|
from general_manager.measurement.measurementField import MeasurementField
|
13
12
|
from datetime import date, datetime, time, timezone
|
14
13
|
|
15
|
-
if TYPE_CHECKING:
|
16
|
-
from general_manager.interface.databaseInterface import (
|
17
|
-
DBBasedInterface,
|
18
|
-
)
|
19
|
-
|
20
|
-
modelsModel = TypeVar("modelsModel", bound=models.Model)
|
21
|
-
|
22
|
-
|
23
|
-
class AutoFactory(DjangoModelFactory[modelsModel]):
|
24
|
-
"""
|
25
|
-
A factory class that automatically generates values for model fields,
|
26
|
-
including handling of unique fields and constraints.
|
27
|
-
"""
|
28
|
-
|
29
|
-
interface: Type[DBBasedInterface]
|
30
|
-
_adjustmentMethod: (
|
31
|
-
Callable[..., Union[dict[str, Any], list[dict[str, Any]]]] | None
|
32
|
-
) = None
|
33
|
-
|
34
|
-
@classmethod
|
35
|
-
def _generate(
|
36
|
-
cls, strategy: Literal["build", "create"], params: dict[str, Any]
|
37
|
-
) -> models.Model | list[models.Model]:
|
38
|
-
cls._original_params = params
|
39
|
-
model = getattr(cls._meta, "model")
|
40
|
-
if not issubclass(model, models.Model):
|
41
|
-
raise ValueError("Model must be a type")
|
42
|
-
field_name_list, to_ignore_list = cls.interface.handleCustomFields(model)
|
43
|
-
|
44
|
-
fields = [
|
45
|
-
field
|
46
|
-
for field in model._meta.get_fields()
|
47
|
-
if field.name not in to_ignore_list
|
48
|
-
]
|
49
|
-
special_fields: list[models.Field[Any, Any]] = [
|
50
|
-
getattr(model, field_name) for field_name in field_name_list
|
51
|
-
]
|
52
|
-
pre_declations = getattr(cls._meta, "pre_declarations", [])
|
53
|
-
post_declarations = getattr(cls._meta, "post_declarations", [])
|
54
|
-
declared_fields: set[str] = set(pre_declations) | set(post_declarations)
|
55
|
-
|
56
|
-
field_list: list[models.Field[Any, Any] | models.ForeignObjectRel] = [
|
57
|
-
*fields,
|
58
|
-
*special_fields,
|
59
|
-
]
|
60
|
-
|
61
|
-
for field in field_list:
|
62
|
-
if field.name in [*params, *declared_fields]:
|
63
|
-
continue # Skip fields that are already set
|
64
|
-
if isinstance(field, models.AutoField) or field.auto_created:
|
65
|
-
continue # Skip auto fields
|
66
|
-
params[field.name] = getFieldValue(field)
|
67
|
-
|
68
|
-
obj: list[models.Model] | models.Model = super()._generate(strategy, params)
|
69
|
-
if isinstance(obj, list):
|
70
|
-
for item in obj: # type: ignore
|
71
|
-
if not isinstance(item, models.Model):
|
72
|
-
raise ValueError("Model must be a type")
|
73
|
-
cls._handleManyToManyFieldsAfterCreation(item, params)
|
74
|
-
else:
|
75
|
-
cls._handleManyToManyFieldsAfterCreation(obj, params)
|
76
|
-
return obj
|
77
|
-
|
78
|
-
@classmethod
|
79
|
-
def _handleManyToManyFieldsAfterCreation(
|
80
|
-
cls, obj: models.Model, attrs: dict[str, Any]
|
81
|
-
) -> None:
|
82
|
-
for field in obj._meta.many_to_many:
|
83
|
-
if field.name in attrs:
|
84
|
-
m2m_values = attrs[field.name]
|
85
|
-
else:
|
86
|
-
m2m_values = getManyToManyFieldValue(field)
|
87
|
-
if m2m_values:
|
88
|
-
getattr(obj, field.name).set(m2m_values)
|
89
|
-
|
90
|
-
@classmethod
|
91
|
-
def _adjust_kwargs(cls, **kwargs: dict[str, Any]) -> dict[str, Any]:
|
92
|
-
# Remove ManyToMany fields from kwargs before object creation
|
93
|
-
model: Type[models.Model] = getattr(cls._meta, "model")
|
94
|
-
m2m_fields = {field.name for field in model._meta.many_to_many}
|
95
|
-
for field_name in m2m_fields:
|
96
|
-
kwargs.pop(field_name, None)
|
97
|
-
return kwargs
|
98
|
-
|
99
|
-
@classmethod
|
100
|
-
def _create(
|
101
|
-
cls, model_class: Type[models.Model], *args: list[Any], **kwargs: dict[str, Any]
|
102
|
-
) -> models.Model | list[models.Model]:
|
103
|
-
kwargs = cls._adjust_kwargs(**kwargs)
|
104
|
-
if cls._adjustmentMethod is not None:
|
105
|
-
return cls.__createWithGenerateFunc(strategy=True, params=kwargs)
|
106
|
-
return cls._modelCreation(model_class, **kwargs)
|
107
|
-
|
108
|
-
@classmethod
|
109
|
-
def _build(
|
110
|
-
cls, model_class: Type[models.Model], *args: list[Any], **kwargs: dict[str, Any]
|
111
|
-
) -> models.Model | list[models.Model]:
|
112
|
-
kwargs = cls._adjust_kwargs(**kwargs)
|
113
|
-
if cls._adjustmentMethod is not None:
|
114
|
-
return cls.__createWithGenerateFunc(strategy=False, params=kwargs)
|
115
|
-
return cls._modelBuilding(model_class, **kwargs)
|
116
|
-
|
117
|
-
@classmethod
|
118
|
-
def _modelCreation(
|
119
|
-
cls, model_class: Type[models.Model], **kwargs: dict[str, Any]
|
120
|
-
) -> models.Model:
|
121
|
-
obj = model_class()
|
122
|
-
for field, value in kwargs.items():
|
123
|
-
setattr(obj, field, value)
|
124
|
-
obj.full_clean()
|
125
|
-
obj.save()
|
126
|
-
return obj
|
127
|
-
|
128
|
-
@classmethod
|
129
|
-
def _modelBuilding(
|
130
|
-
cls, model_class: Type[models.Model], **kwargs: dict[str, Any]
|
131
|
-
) -> models.Model:
|
132
|
-
obj = model_class()
|
133
|
-
for field, value in kwargs.items():
|
134
|
-
setattr(obj, field, value)
|
135
|
-
return obj
|
136
|
-
|
137
|
-
@classmethod
|
138
|
-
def __createWithGenerateFunc(
|
139
|
-
cls, strategy: bool, params: dict[str, Any]
|
140
|
-
) -> models.Model | list[models.Model]:
|
141
|
-
model_cls = getattr(cls._meta, "model")
|
142
|
-
if cls._adjustmentMethod is None:
|
143
|
-
raise ValueError("generate_func is not defined")
|
144
|
-
records = cls._adjustmentMethod(**params)
|
145
|
-
if isinstance(records, dict):
|
146
|
-
if strategy:
|
147
|
-
return cls._modelCreation(model_cls, **records)
|
148
|
-
return cls._modelBuilding(model_cls, **records)
|
149
|
-
|
150
|
-
created_objects: list[models.Model] = []
|
151
|
-
for record in records:
|
152
|
-
if strategy:
|
153
|
-
created_objects.append(cls._modelCreation(model_cls, **record))
|
154
|
-
else:
|
155
|
-
created_objects.append(cls._modelBuilding(model_cls, **record))
|
156
|
-
return created_objects
|
157
|
-
|
158
14
|
|
159
15
|
def getFieldValue(field: models.Field[Any, Any] | models.ForeignObjectRel) -> object:
|
160
16
|
"""
|
161
|
-
|
17
|
+
Generates an appropriate value for a given Django model field for use in testing or data factories.
|
18
|
+
|
19
|
+
If the field allows null values, there is a 10% chance of returning None. Handles a wide range of Django field types, including measurement, text, numeric, date/time, boolean, relational, and specialized fields, returning a suitable fake or factory-generated value for each. For relational fields (OneToOneField and ForeignKey), attempts to use a factory if available or selects a random existing instance; raises ValueError if neither is possible. Returns None for unsupported field types.
|
162
20
|
"""
|
163
21
|
if field.null:
|
164
22
|
if random.choice([True] + 9 * [False]):
|
@@ -18,7 +18,7 @@ from simple_history.models import HistoricalRecords # type: ignore
|
|
18
18
|
from general_manager.measurement.measurement import Measurement
|
19
19
|
from general_manager.measurement.measurementField import MeasurementField
|
20
20
|
from decimal import Decimal
|
21
|
-
from general_manager.factory.
|
21
|
+
from general_manager.factory.autoFactory import AutoFactory
|
22
22
|
from django.core.exceptions import ValidationError
|
23
23
|
from general_manager.interface.baseInterface import (
|
24
24
|
InterfaceBase,
|
@@ -646,13 +646,13 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
646
646
|
self, basis: dict[str, list[Any]], **kwargs: Any
|
647
647
|
) -> dict[str, list[Any]]:
|
648
648
|
"""
|
649
|
-
|
649
|
+
Combines existing filter definitions with additional keyword arguments.
|
650
650
|
|
651
651
|
Args:
|
652
|
-
basis:
|
652
|
+
basis: Dictionary mapping filter keys to lists of values. Additional keyword arguments are merged into this dictionary.
|
653
653
|
|
654
654
|
Returns:
|
655
|
-
A dictionary where each key maps to a list
|
655
|
+
A dictionary where each key maps to a list containing all values from both the original basis and the new keyword arguments.
|
656
656
|
"""
|
657
657
|
kwarg_filter: dict[str, list[Any]] = {}
|
658
658
|
for key, value in basis.items():
|
@@ -665,9 +665,9 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
665
665
|
|
666
666
|
def filter(self, **kwargs: Any) -> DatabaseBucket[GeneralManagerType]:
|
667
667
|
"""
|
668
|
-
Returns a new bucket
|
668
|
+
Returns a new bucket with manager instances matching the specified filter criteria.
|
669
669
|
|
670
|
-
Additional filter keyword arguments are merged with existing filters to
|
670
|
+
Additional filter keyword arguments are merged with any existing filters to further restrict the queryset.
|
671
671
|
"""
|
672
672
|
merged_filter = self.__mergeFilterDefinitions(self.filters, **kwargs)
|
673
673
|
return self.__class__(
|
@@ -679,13 +679,9 @@ class DatabaseBucket(Bucket[GeneralManagerType]):
|
|
679
679
|
|
680
680
|
def exclude(self, **kwargs: Any) -> DatabaseBucket[GeneralManagerType]:
|
681
681
|
"""
|
682
|
-
Returns a new
|
682
|
+
Returns a new DatabaseBucket excluding items that match the specified criteria.
|
683
683
|
|
684
|
-
|
685
|
-
**kwargs: Field lookups to exclude from the queryset.
|
686
|
-
|
687
|
-
Returns:
|
688
|
-
A DatabaseBucket containing items not matching the specified filters.
|
684
|
+
Keyword arguments specify field lookups to exclude from the queryset. The resulting bucket contains only items that do not match these filters.
|
689
685
|
"""
|
690
686
|
merged_exclude = self.__mergeFilterDefinitions(self.excludes, **kwargs)
|
691
687
|
return self.__class__(
|
@@ -128,15 +128,31 @@ class GeneralManager(Generic[GeneralManagerType], metaclass=GeneralManagerMeta):
|
|
128
128
|
|
129
129
|
@staticmethod
|
130
130
|
def __parse_identification(kwargs: dict[str, Any]) -> dict[str, Any] | None:
|
131
|
+
"""
|
132
|
+
Converts a dictionary of keyword arguments by replacing any GeneralManager instances with their identifications.
|
133
|
+
|
134
|
+
For each key-value pair, if the value is a GeneralManager, it is replaced with its identification. Lists and tuples are processed recursively, replacing contained GeneralManager instances with their identifications. Returns a new dictionary with the processed values, or None if the result is empty.
|
135
|
+
|
136
|
+
Args:
|
137
|
+
kwargs: Dictionary of keyword arguments to process.
|
138
|
+
|
139
|
+
Returns:
|
140
|
+
A new dictionary with GeneralManager instances replaced by their identifications, or None if the dictionary is empty.
|
141
|
+
"""
|
142
|
+
output = {}
|
131
143
|
for key, value in kwargs.items():
|
132
144
|
if isinstance(value, GeneralManager):
|
133
|
-
|
145
|
+
output[key] = value.identification
|
134
146
|
elif isinstance(value, list):
|
135
|
-
|
136
|
-
v.identification
|
147
|
+
output[key] = [
|
148
|
+
v.identification if isinstance(v, GeneralManager) else v
|
149
|
+
for v in value
|
137
150
|
]
|
138
151
|
elif isinstance(value, tuple):
|
139
|
-
|
140
|
-
v.identification
|
152
|
+
output[key] = tuple(
|
153
|
+
v.identification if isinstance(v, GeneralManager) else v
|
154
|
+
for v in value
|
141
155
|
)
|
142
|
-
|
156
|
+
else:
|
157
|
+
output[key] = value
|
158
|
+
return output if output else None
|
@@ -16,14 +16,15 @@ general_manager/cache/dependencyIndex.py,sha256=kEbIAzzMzKlQgplKfcMYBPZ562zCBkOB
|
|
16
16
|
general_manager/cache/modelDependencyCollector.py,sha256=wS2edbZsQ1aTfRlHj02lhuasZHCc2ucRGob-E7ejuoY,2433
|
17
17
|
general_manager/cache/signals.py,sha256=ZHeXKFMN7tj9t0J-vSqf_05_NhGqEF2sZtbZO3vaRqI,1234
|
18
18
|
general_manager/factory/__init__.py,sha256=wbPIGyBlWBHa7aGWUd-1IUMPWUS-M6YqtPUL1iKXW8U,93
|
19
|
-
general_manager/factory/
|
19
|
+
general_manager/factory/autoFactory.py,sha256=WBhSuMVsxkPAPLhlZhYXwHVIqiomUveS7vMxw1ON_8Q,9376
|
20
|
+
general_manager/factory/factories.py,sha256=F6_nYFyJRYYc3LQApfoVFdctfLzsWUDHKafn6xjckB8,7224
|
20
21
|
general_manager/factory/factoryMethods.py,sha256=9Bag891j0XHe3dUBAFi7gUKcKeUwcBZN3cDLBobyBiI,3225
|
21
22
|
general_manager/interface/__init__.py,sha256=6x5adQLefTugvrJeyPcAxstyqgLAYeaJ1EPdAbac9pE,213
|
22
23
|
general_manager/interface/baseInterface.py,sha256=mvSKUlA-0fazNnaIXGBwkiZxmX8DM_sOn-SaAIpaW8I,10273
|
23
24
|
general_manager/interface/calculationInterface.py,sha256=GzSNXjU6Z7bFz60gHyMKkI5xNUDIPuniV8wbyVtQT50,14250
|
24
|
-
general_manager/interface/databaseInterface.py,sha256=
|
25
|
+
general_manager/interface/databaseInterface.py,sha256=1hQcgOQkEhniv7Mrx2CbqPaes_qqH9zTqSnlriZQfGo,28314
|
25
26
|
general_manager/manager/__init__.py,sha256=l3RYp62aEhj3Y975_XUTIzo35LUnkTJHkb_hgChnXXI,111
|
26
|
-
general_manager/manager/generalManager.py,sha256=
|
27
|
+
general_manager/manager/generalManager.py,sha256=L470Jevvh87doI5leUbTa9P6weIdekRZ6OTorqN-WpY,6091
|
27
28
|
general_manager/manager/groupManager.py,sha256=O4FABqbm7KlZw6t36Ot3HU1FsBYN0h6Zhmk7ktN8a-Y,10087
|
28
29
|
general_manager/manager/input.py,sha256=iKawV3P1QICz-0AQUF00OvH7LZYxussg3svpvCUl8hE,2977
|
29
30
|
general_manager/manager/meta.py,sha256=5wHrCVnua5c38vpVZSCesrNvgydQDH8h6pxW6_QgCDg,3107
|
@@ -39,8 +40,8 @@ general_manager/permission/permissionDataManager.py,sha256=Ji7fsnuaKTa6M8yzCGyzr
|
|
39
40
|
general_manager/rule/__init__.py,sha256=4Har5cfPD1fmOsilTDod-ZUz3Com-tkl58jz7yY4fD0,23
|
40
41
|
general_manager/rule/handler.py,sha256=z8SFHTIZ0LbLh3fV56Mud0V4_OvWkqJjlHvFqau7Qfk,7334
|
41
42
|
general_manager/rule/rule.py,sha256=3FVCKGL7BTVoStdgOTdWQwuoVRIxAIAilV4VOzouDpc,10759
|
42
|
-
generalmanager-0.4.
|
43
|
-
generalmanager-0.4.
|
44
|
-
generalmanager-0.4.
|
45
|
-
generalmanager-0.4.
|
46
|
-
generalmanager-0.4.
|
43
|
+
generalmanager-0.4.6.dist-info/licenses/LICENSE,sha256=YGFm0ieb4KpkMRRt2qnWue6uFh0cUMtobwEBkHwajhc,1450
|
44
|
+
generalmanager-0.4.6.dist-info/METADATA,sha256=LVkGEqWXis_DYKCLzno3bpZ8hdCLGaG1BBiD_QFezss,6528
|
45
|
+
generalmanager-0.4.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
46
|
+
generalmanager-0.4.6.dist-info/top_level.txt,sha256=sTDtExP9ga-YP3h3h42yivUY-A2Q23C2nw6LNKOho4I,16
|
47
|
+
generalmanager-0.4.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|