tiferet 1.0.0a19__py3-none-any.whl → 1.0.0b0__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.
- tiferet/__init__.py +3 -2
- tiferet/commands/__init__.py +6 -0
- tiferet/commands/app.py +102 -0
- tiferet/commands/core.py +124 -0
- tiferet/commands/dependencies.py +76 -0
- tiferet/commands/settings.py +101 -0
- tiferet/configs/__init__.py +3 -67
- tiferet/configs/error.py +48 -0
- tiferet/configs/settings.py +37 -0
- tiferet/contexts/__init__.py +0 -8
- tiferet/contexts/app.py +215 -182
- tiferet/contexts/cache.py +76 -0
- tiferet/contexts/container.py +92 -190
- tiferet/contexts/error.py +78 -80
- tiferet/contexts/feature.py +120 -83
- tiferet/contracts/__init__.py +4 -0
- tiferet/contracts/app.py +92 -0
- tiferet/contracts/cache.py +70 -0
- tiferet/contracts/container.py +147 -0
- tiferet/contracts/error.py +177 -0
- tiferet/contracts/feature.py +159 -0
- tiferet/contracts/settings.py +34 -0
- tiferet/data/__init__.py +3 -4
- tiferet/data/app.py +71 -208
- tiferet/data/container.py +52 -38
- tiferet/data/error.py +15 -24
- tiferet/data/feature.py +27 -8
- tiferet/{domain/core.py → data/settings.py} +36 -96
- tiferet/handlers/__init__.py +0 -0
- tiferet/handlers/container.py +116 -0
- tiferet/handlers/error.py +49 -0
- tiferet/handlers/feature.py +94 -0
- tiferet/models/__init__.py +4 -0
- tiferet/models/app.py +150 -0
- tiferet/models/container.py +135 -0
- tiferet/{domain → models}/error.py +86 -36
- tiferet/{domain → models}/feature.py +107 -47
- tiferet/models/settings.py +148 -0
- tiferet/proxies/__init__.py +0 -0
- tiferet/proxies/yaml/__init__.py +0 -0
- tiferet/{repos → proxies/yaml}/app.py +13 -41
- tiferet/{repos → proxies/yaml}/container.py +26 -56
- tiferet/{repos → proxies/yaml}/error.py +11 -70
- tiferet/proxies/yaml/feature.py +92 -0
- {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info}/METADATA +12 -3
- tiferet-1.0.0b0.dist-info/RECORD +51 -0
- {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info}/WHEEL +1 -1
- tiferet/commands/container.py +0 -54
- tiferet/commands/error.py +0 -21
- tiferet/commands/feature.py +0 -90
- tiferet/contexts/request.py +0 -110
- tiferet/domain/__init__.py +0 -5
- tiferet/domain/app.py +0 -131
- tiferet/domain/container.py +0 -141
- tiferet/repos/__init__.py +0 -7
- tiferet/repos/feature.py +0 -151
- tiferet-1.0.0a19.dist-info/RECORD +0 -35
- {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info/licenses}/LICENSE +0 -0
- {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info}/top_level.txt +0 -0
tiferet/data/app.py
CHANGED
@@ -1,70 +1,35 @@
|
|
1
1
|
# *** imports
|
2
2
|
|
3
|
-
# ** core
|
4
|
-
from typing import Dict
|
5
|
-
|
6
3
|
# ** app
|
7
|
-
from
|
8
|
-
from ..
|
9
|
-
from ..
|
10
|
-
|
11
|
-
|
12
|
-
# *** constants
|
13
|
-
|
14
|
-
# ** constant: app_dependency_default
|
15
|
-
FEATURE_CONTEXT_DEFAULT = dict(
|
16
|
-
module_path='tiferet.contexts.feature',
|
17
|
-
class_name='FeatureContext',
|
18
|
-
)
|
19
|
-
|
20
|
-
# * constant: app_dependency_default
|
21
|
-
CONTAINER_CONTEXT_DEFAULT = dict(
|
22
|
-
module_path='tiferet.contexts.container',
|
23
|
-
class_name='ContainerContext',
|
24
|
-
)
|
25
|
-
|
26
|
-
ERROR_CONTEXT_DEFAULT = dict(
|
27
|
-
module_path='tiferet.contexts.error',
|
28
|
-
class_name='ErrorContext',
|
29
|
-
)
|
30
|
-
|
31
|
-
FEATURE_REPO_DEFAULT = dict(
|
32
|
-
module_path='tiferet.repos.feature',
|
33
|
-
class_name='YamlProxy',
|
34
|
-
)
|
35
|
-
|
36
|
-
CONTAINER_REPO_DEFAULT = dict(
|
37
|
-
module_path='tiferet.repos.container',
|
38
|
-
class_name='YamlProxy',
|
39
|
-
)
|
4
|
+
from .settings import *
|
5
|
+
from ..models.app import *
|
6
|
+
from ..contracts.app import AppAttribute as AppAttributeContract
|
7
|
+
from ..contracts.app import AppInterface as AppInterfaceContract
|
40
8
|
|
41
|
-
ERROR_REPO_DEFAULT = dict(
|
42
|
-
module_path='tiferet.repos.error',
|
43
|
-
class_name='YamlProxy',
|
44
|
-
)
|
45
|
-
|
46
|
-
# ** constant: context_list_default
|
47
|
-
CONTEXT_LIST_DEFAULT = {
|
48
|
-
'feature_context': FEATURE_CONTEXT_DEFAULT,
|
49
|
-
'container_context': CONTAINER_CONTEXT_DEFAULT,
|
50
|
-
'error_context': ERROR_CONTEXT_DEFAULT,
|
51
|
-
'feature_repo': FEATURE_REPO_DEFAULT,
|
52
|
-
'container_repo': CONTAINER_REPO_DEFAULT,
|
53
|
-
'error_repo': ERROR_REPO_DEFAULT,
|
54
|
-
}
|
55
9
|
|
56
10
|
# *** data
|
57
11
|
|
58
|
-
# ** data:
|
59
|
-
class
|
12
|
+
# ** data: app_attribute_yaml_data
|
13
|
+
class AppAttributeYamlData(AppAttribute, DataObject):
|
60
14
|
'''
|
61
|
-
A YAML data representation of an app dependency object.
|
15
|
+
A YAML data representation of an app dependency attribute object.
|
62
16
|
'''
|
63
17
|
|
64
18
|
# * attribute: attribute_id
|
65
19
|
attribute_id = StringType(
|
66
20
|
metadata=dict(
|
67
|
-
description='The attribute id for the application dependency.'
|
21
|
+
description='The attribute id for the application dependency that is not required for assembly.'
|
22
|
+
),
|
23
|
+
)
|
24
|
+
|
25
|
+
# * attribute: parameters
|
26
|
+
parameters = DictType(
|
27
|
+
StringType,
|
28
|
+
default={},
|
29
|
+
serialized_name='params',
|
30
|
+
deserialize_from=['params', 'parameters'],
|
31
|
+
metadata=dict(
|
32
|
+
description='The parameters for the application dependency that are not required for assembly.'
|
68
33
|
),
|
69
34
|
)
|
70
35
|
|
@@ -74,67 +39,37 @@ class AppDependencyYamlData(AppDependency, DataObject):
|
|
74
39
|
'''
|
75
40
|
serialize_when_none = False
|
76
41
|
roles = {
|
77
|
-
'to_model': DataObject.
|
42
|
+
'to_model': DataObject.deny('parameters', 'attribute_id'),
|
78
43
|
'to_data.yaml': DataObject.deny('attribute_id')
|
79
44
|
}
|
80
45
|
|
81
|
-
# * method: from_data
|
82
|
-
@staticmethod
|
83
|
-
def from_data(**kwargs) -> 'AppDependencyYamlData':
|
84
|
-
'''
|
85
|
-
Initializes a new YAML representation of an AppDependency object.
|
86
|
-
|
87
|
-
:param kwargs: Additional keyword arguments.
|
88
|
-
:type kwargs: dict
|
89
|
-
:return: A new AppDependencyData object.
|
90
|
-
:rtype: AppDependencyData
|
91
|
-
'''
|
92
|
-
|
93
|
-
# Create a new AppDependencyData object.
|
94
|
-
return super(AppDependencyYamlData, AppDependencyYamlData).from_data(
|
95
|
-
AppDependencyYamlData,
|
96
|
-
**kwargs
|
97
|
-
)
|
98
|
-
|
99
|
-
# * method: new
|
100
|
-
@staticmethod
|
101
|
-
def from_data(**kwargs) -> 'AppDependencyYamlData':
|
102
|
-
'''
|
103
|
-
Initializes a new YAML representation of an AppDependency object.
|
104
|
-
|
105
|
-
:param kwargs: Additional keyword arguments.
|
106
|
-
:type kwargs: dict
|
107
|
-
:return: A new AppDependencyData object.
|
108
|
-
:rtype: AppDependencyData
|
109
|
-
'''
|
110
|
-
|
111
|
-
# Create a new AppDependencyData object.
|
112
|
-
return super(AppDependencyYamlData, AppDependencyYamlData).from_data(
|
113
|
-
AppDependencyYamlData,
|
114
|
-
**kwargs
|
115
|
-
)
|
116
|
-
|
117
46
|
# * method: map
|
118
|
-
def map(self, **kwargs) ->
|
47
|
+
def map(self, attribute_id: str, **kwargs) -> AppAttributeContract:
|
119
48
|
'''
|
120
49
|
Maps the app dependency data to an app dependency object.
|
121
50
|
|
122
|
-
:param
|
123
|
-
:type
|
51
|
+
:param attribute_id: The id for the app dependency attribute.
|
52
|
+
:type attribute_id: str
|
124
53
|
:param kwargs: Additional keyword arguments.
|
125
54
|
:type kwargs: dict
|
126
|
-
:return: A new app dependency
|
127
|
-
:rtype:
|
55
|
+
:return: A new app attribute dependency contract.
|
56
|
+
:rtype: AppAttributeContract
|
128
57
|
'''
|
129
58
|
|
130
|
-
# Map the app dependency
|
131
|
-
return super().map(
|
59
|
+
# Map to the app dependency object.
|
60
|
+
return super().map(
|
61
|
+
AppAttribute,
|
62
|
+
attribute_id=attribute_id,
|
63
|
+
parameters=self.parameters,
|
64
|
+
**self.to_primitive('to_model'),
|
65
|
+
**kwargs
|
66
|
+
)
|
132
67
|
|
133
68
|
|
134
69
|
# ** data: app_interface_yaml_data
|
135
70
|
class AppInterfaceYamlData(AppInterface, DataObject):
|
136
71
|
'''
|
137
|
-
A data representation of an app interface object.
|
72
|
+
A data representation of an app interface settings object.
|
138
73
|
'''
|
139
74
|
|
140
75
|
class Options():
|
@@ -143,143 +78,71 @@ class AppInterfaceYamlData(AppInterface, DataObject):
|
|
143
78
|
'''
|
144
79
|
serialize_when_none = False
|
145
80
|
roles = {
|
146
|
-
'to_model': DataObject.deny('
|
147
|
-
'to_data': DataObject.deny('id')
|
81
|
+
'to_model': DataObject.deny('attributes', 'constants', 'module_path', 'class_name'),
|
82
|
+
'to_data.yaml': DataObject.deny('id')
|
148
83
|
}
|
149
84
|
|
150
|
-
# attribute:
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
description='The application context dependency.'
|
156
|
-
),
|
157
|
-
)
|
158
|
-
|
159
|
-
# * attribute: feature_context
|
160
|
-
feature_context = ModelType(
|
161
|
-
AppDependencyYamlData,
|
162
|
-
required=True,
|
163
|
-
metadata=dict(
|
164
|
-
description='The feature context dependency.'
|
165
|
-
),
|
166
|
-
)
|
167
|
-
|
168
|
-
# * attribute: container_context
|
169
|
-
container_context = ModelType(
|
170
|
-
AppDependencyYamlData,
|
171
|
-
required=True,
|
172
|
-
metadata=dict(
|
173
|
-
description='The container context dependency.'
|
174
|
-
),
|
175
|
-
)
|
176
|
-
|
177
|
-
# * attribute: error_context
|
178
|
-
error_context = ModelType(
|
179
|
-
AppDependencyYamlData,
|
180
|
-
required=True,
|
85
|
+
# * attribute: module_path
|
86
|
+
module_path = StringType(
|
87
|
+
default=DEFAULT_MODULE_PATH,
|
88
|
+
serialized_name='module',
|
89
|
+
deserialize_from=['module_path', 'module'],
|
181
90
|
metadata=dict(
|
182
|
-
description='The
|
91
|
+
description='The app context module path for the app settings.'
|
183
92
|
),
|
184
93
|
)
|
185
94
|
|
186
|
-
# * attribute:
|
187
|
-
|
188
|
-
|
189
|
-
|
95
|
+
# * attribute: class_name
|
96
|
+
class_name = StringType(
|
97
|
+
default=DEFAULT_CLASS_NAME,
|
98
|
+
serialized_name='class',
|
99
|
+
deserialize_from=['class_name', 'class'],
|
190
100
|
metadata=dict(
|
191
|
-
description='The
|
101
|
+
description='The class name for the app context.'
|
192
102
|
),
|
193
103
|
)
|
194
104
|
|
195
|
-
# * attribute:
|
196
|
-
|
197
|
-
|
198
|
-
|
105
|
+
# * attribute: attributes
|
106
|
+
attributes = DictType(
|
107
|
+
ModelType(AppAttributeYamlData),
|
108
|
+
default={},
|
109
|
+
serialized_name='attrs',
|
110
|
+
deserialize_from=['attrs', 'attributes'],
|
199
111
|
metadata=dict(
|
200
|
-
description='The
|
112
|
+
description='The app instance attributes.'
|
201
113
|
),
|
202
114
|
)
|
203
115
|
|
204
|
-
# * attribute:
|
205
|
-
|
206
|
-
|
207
|
-
|
116
|
+
# * attribute: constants
|
117
|
+
constants = DictType(
|
118
|
+
StringType,
|
119
|
+
default={},
|
120
|
+
serialized_name='const',
|
121
|
+
deserialize_from=['constants', 'const'],
|
208
122
|
metadata=dict(
|
209
|
-
description='The
|
123
|
+
description='The constants for the app settings.'
|
210
124
|
),
|
211
125
|
)
|
212
126
|
|
213
|
-
# * method: new
|
214
|
-
@staticmethod
|
215
|
-
def from_data(app_context: Dict[str, str],
|
216
|
-
**kwargs) -> 'AppInterfaceYamlData':
|
217
|
-
'''
|
218
|
-
Initializes a new YAML representation of an AppInterface object.
|
219
|
-
|
220
|
-
:param kwargs: Additional keyword arguments.
|
221
|
-
:type kwargs: dict
|
222
|
-
:return: A new AppInterfaceData object.
|
223
|
-
:rtype: AppInterfaceData
|
224
|
-
'''
|
225
|
-
|
226
|
-
# Add the app context to the dependencies.
|
227
|
-
dependencies = dict(
|
228
|
-
app_context=AppDependencyYamlData.from_data(
|
229
|
-
attribute_id='app_context',
|
230
|
-
**app_context
|
231
|
-
)
|
232
|
-
)
|
233
|
-
|
234
|
-
# Going through the default dependencies...
|
235
|
-
for key, value in CONTEXT_LIST_DEFAULT.items():
|
236
|
-
|
237
|
-
# If the key is in the kwargs, add it and continue.
|
238
|
-
if key in kwargs:
|
239
|
-
dependencies[key] = AppDependencyYamlData.from_data(
|
240
|
-
attribute_id=key,
|
241
|
-
**kwargs.pop(key)) # Pop the key to avoid duplication.
|
242
|
-
continue
|
243
|
-
|
244
|
-
# Otherwise, add the default value.
|
245
|
-
dependencies[key] = AppDependencyYamlData.from_data(
|
246
|
-
attribute_id=key,
|
247
|
-
**value)
|
248
|
-
|
249
|
-
# Create a new AppInterfaceData object.
|
250
|
-
return super(AppInterfaceYamlData, AppInterfaceYamlData).from_data(
|
251
|
-
AppInterfaceYamlData,
|
252
|
-
**dependencies,
|
253
|
-
**kwargs
|
254
|
-
)
|
255
|
-
|
256
127
|
# * method: map
|
257
|
-
def map(self, **kwargs) ->
|
128
|
+
def map(self, **kwargs) -> AppInterfaceContract:
|
258
129
|
'''
|
259
|
-
Maps the app interface data to an app interface
|
130
|
+
Maps the app interface data to an app interface contract.
|
260
131
|
|
261
132
|
:param role: The role for the mapping.
|
262
133
|
:type role: str
|
263
134
|
:param kwargs: Additional keyword arguments.
|
264
135
|
:type kwargs: dict
|
265
|
-
:return: A new app interface
|
266
|
-
:rtype:
|
136
|
+
:return: A new app interface contract.
|
137
|
+
:rtype: AppInterfaceContract
|
267
138
|
'''
|
268
139
|
|
269
|
-
# Format and map the dependencies.
|
270
|
-
dependencies = [
|
271
|
-
self.app_context.map(),
|
272
|
-
self.container_context.map(),
|
273
|
-
self.feature_context.map(),
|
274
|
-
self.error_context.map(),
|
275
|
-
self.feature_repo.map(),
|
276
|
-
self.container_repo.map(),
|
277
|
-
self.error_repo.map(),
|
278
|
-
]
|
279
|
-
|
280
140
|
# Map the app interface data.
|
281
141
|
return super().map(AppInterface,
|
282
|
-
|
142
|
+
module_path=self.module_path,
|
143
|
+
class_name=self.class_name,
|
144
|
+
attributes=[attr.map(attribute_id=attr_id) for attr_id, attr in self.attributes.items()],
|
145
|
+
constants=self.constants,
|
283
146
|
**self.to_primitive('to_model'),
|
284
147
|
**kwargs
|
285
|
-
)
|
148
|
+
)
|
tiferet/data/container.py
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
# *** imports
|
2
2
|
|
3
|
-
# ** core
|
4
|
-
from typing import Any, Dict
|
5
|
-
|
6
3
|
# ** app
|
7
|
-
from ..
|
8
|
-
from ..
|
9
|
-
from ..
|
4
|
+
from ..data import *
|
5
|
+
from ..models.container import *
|
6
|
+
from ..contracts.container import (
|
7
|
+
ContainerAttribute as ContainerAttributeContract,
|
8
|
+
FlaggedDependency as FlaggedDependencyContract
|
9
|
+
)
|
10
10
|
|
11
11
|
|
12
12
|
# *** data
|
13
13
|
|
14
|
-
# ** data:
|
15
|
-
class
|
14
|
+
# ** data: flagged_dependency_yaml_data
|
15
|
+
class FlaggedDependencyYamlData(FlaggedDependency, DataObject):
|
16
16
|
'''
|
17
|
-
A data representation of a
|
17
|
+
A data representation of a flagged dependency object.
|
18
18
|
'''
|
19
19
|
|
20
20
|
class Options():
|
21
21
|
'''
|
22
|
-
The options for the
|
22
|
+
The options for the flagged dependency data.
|
23
23
|
'''
|
24
24
|
|
25
25
|
serialize_when_none = False
|
@@ -47,17 +47,18 @@ class ContainerDependencyYamlData(ContainerDependency, DataObject):
|
|
47
47
|
)
|
48
48
|
|
49
49
|
# * method: map
|
50
|
-
def map(self, **kwargs) ->
|
50
|
+
def map(self, **kwargs) -> FlaggedDependencyContract:
|
51
51
|
'''
|
52
|
-
Maps the
|
52
|
+
Maps the flagged dependency data to a flagged dependency object.
|
53
53
|
|
54
54
|
:param role: The role for the mapping.
|
55
55
|
:type role: str
|
56
|
-
:return: A new
|
56
|
+
:return: A new flagged dependency object.
|
57
|
+
:rtype: FlaggedDependencyContract
|
57
58
|
'''
|
58
59
|
|
59
60
|
# Map to the container dependency object.
|
60
|
-
obj = super().map(
|
61
|
+
obj = super().map(FlaggedDependency, **kwargs, validate=False)
|
61
62
|
|
62
63
|
# Set the parameters in due to the deserializer.
|
63
64
|
obj.parameters = self.parameters
|
@@ -68,40 +69,40 @@ class ContainerDependencyYamlData(ContainerDependency, DataObject):
|
|
68
69
|
|
69
70
|
# * method: new
|
70
71
|
@staticmethod
|
71
|
-
def from_data(**kwargs) -> '
|
72
|
+
def from_data(**kwargs) -> 'FlaggedDependencyYamlData':
|
72
73
|
'''
|
73
|
-
Initializes a new
|
74
|
+
Initializes a new ContainerDependencyYamlData object from YAML data.
|
74
75
|
|
75
76
|
:param kwargs: Additional keyword arguments.
|
76
77
|
:type kwargs: dict
|
77
|
-
:return: A new
|
78
|
+
:return: A new ContainerDependencyYamlData object.
|
78
79
|
:rtype: ContainerDependencyYamlData
|
79
80
|
'''
|
80
81
|
|
81
|
-
# Create a new
|
82
|
+
# Create a new ContainerDependencyYamlData object.
|
82
83
|
return super(
|
83
|
-
|
84
|
-
|
84
|
+
FlaggedDependencyYamlData,
|
85
|
+
FlaggedDependencyYamlData
|
85
86
|
).from_data(
|
86
|
-
|
87
|
+
FlaggedDependencyYamlData,
|
87
88
|
**kwargs
|
88
89
|
)
|
89
90
|
|
90
91
|
# * method: from_model
|
91
92
|
@staticmethod
|
92
|
-
def from_model(model:
|
93
|
+
def from_model(model: FlaggedDependency, **kwargs) -> 'FlaggedDependencyYamlData':
|
93
94
|
'''
|
94
|
-
Initializes a new
|
95
|
+
Initializes a new ContainerDependencyYamlData object from a model object.
|
95
96
|
|
96
|
-
:param model: The
|
97
|
-
:type model:
|
97
|
+
:param model: The flagged dependency model object.
|
98
|
+
:type model: FlaggedDependency
|
98
99
|
:param kwargs: Additional keyword arguments.
|
99
100
|
:type kwargs: dict
|
100
101
|
'''
|
101
102
|
|
102
|
-
# Create and return a new
|
103
|
-
return super(
|
104
|
-
|
103
|
+
# Create and return a new FlaggedDependencyYamlData object.
|
104
|
+
return super(FlaggedDependencyYamlData, FlaggedDependencyYamlData).from_model(
|
105
|
+
FlaggedDependencyYamlData,
|
105
106
|
model,
|
106
107
|
**kwargs,
|
107
108
|
)
|
@@ -120,14 +121,14 @@ class ContainerAttributeYamlData(ContainerAttribute, DataObject):
|
|
120
121
|
|
121
122
|
serialize_when_none = False
|
122
123
|
roles = {
|
123
|
-
'to_model': DataObject.
|
124
|
+
'to_model': DataObject.deny('params'),
|
124
125
|
'to_data': DataObject.deny('id')
|
125
126
|
}
|
126
127
|
|
127
128
|
# * attribute: dependencies
|
128
129
|
dependencies = DictType(
|
129
|
-
ModelType(
|
130
|
-
default=
|
130
|
+
ModelType(FlaggedDependencyYamlData),
|
131
|
+
default={},
|
131
132
|
serialized_name='deps',
|
132
133
|
deserialize_from=['deps', 'dependencies'],
|
133
134
|
metadata=dict(
|
@@ -135,25 +136,39 @@ class ContainerAttributeYamlData(ContainerAttribute, DataObject):
|
|
135
136
|
),
|
136
137
|
)
|
137
138
|
|
139
|
+
# * attribute: parameters
|
140
|
+
parameters = DictType(
|
141
|
+
StringType,
|
142
|
+
default={},
|
143
|
+
serialized_name='params',
|
144
|
+
deserialize_from=['params'],
|
145
|
+
metadata=dict(
|
146
|
+
description='The default parameters for the container attribute.'
|
147
|
+
),
|
148
|
+
)
|
149
|
+
|
138
150
|
# * method: map
|
139
|
-
def map(self, **kwargs) ->
|
151
|
+
def map(self, **kwargs) -> ContainerAttributeContract:
|
140
152
|
'''
|
141
153
|
Maps the container attribute data to a container attribute object.
|
142
154
|
|
143
155
|
:param kwargs: Additional keyword arguments.
|
144
156
|
:type kwargs: dict
|
157
|
+
:return: A container attribute model contract.
|
158
|
+
:rtype: ContainerAttributeContract
|
145
159
|
'''
|
146
160
|
|
147
161
|
# Map to the container attribute object with the dependencies.
|
148
162
|
return super().map(ContainerAttribute,
|
149
163
|
dependencies=[dep.map(flag=flag) for flag, dep in self.dependencies.items()],
|
164
|
+
parameters=self.parameters,
|
150
165
|
**kwargs)
|
151
166
|
|
152
167
|
# * method: new
|
153
168
|
@staticmethod
|
154
169
|
def from_data(**kwargs) -> 'ContainerAttributeYamlData':
|
155
170
|
'''
|
156
|
-
Initializes a new
|
171
|
+
Initializes a new ContainerAttributeYamlData object from YAML data.
|
157
172
|
|
158
173
|
:param deps: The dependencies data.
|
159
174
|
:type deps: dict
|
@@ -161,7 +176,7 @@ class ContainerAttributeYamlData(ContainerAttribute, DataObject):
|
|
161
176
|
:type kwargs: dict
|
162
177
|
'''
|
163
178
|
|
164
|
-
# Create a new
|
179
|
+
# Create a new ContainerAttributeYamlData object.
|
165
180
|
obj = super(
|
166
181
|
ContainerAttributeYamlData,
|
167
182
|
ContainerAttributeYamlData
|
@@ -183,7 +198,7 @@ class ContainerAttributeYamlData(ContainerAttribute, DataObject):
|
|
183
198
|
@staticmethod
|
184
199
|
def from_model(model: ContainerAttribute, **kwargs) -> 'ContainerAttributeYamlData':
|
185
200
|
'''
|
186
|
-
Initializes a new
|
201
|
+
Initializes a new ContainerAttributeYamlData object from a model object.
|
187
202
|
|
188
203
|
:param model: The container attribute model object.
|
189
204
|
:type model: ContainerAttribute
|
@@ -198,7 +213,7 @@ class ContainerAttributeYamlData(ContainerAttribute, DataObject):
|
|
198
213
|
data = model.to_primitive()
|
199
214
|
data['dependencies'] = dependencies
|
200
215
|
|
201
|
-
# Create a new
|
216
|
+
# Create a new ContainerAttributeYamlData object.
|
202
217
|
obj = ContainerAttributeYamlData(
|
203
218
|
dict(
|
204
219
|
**data,
|
@@ -209,5 +224,4 @@ class ContainerAttributeYamlData(ContainerAttribute, DataObject):
|
|
209
224
|
|
210
225
|
# Validate and return the object.
|
211
226
|
obj.validate()
|
212
|
-
return obj
|
213
|
-
|
227
|
+
return obj
|
tiferet/data/error.py
CHANGED
@@ -2,26 +2,13 @@
|
|
2
2
|
|
3
3
|
# ** app
|
4
4
|
from ..configs import *
|
5
|
-
from ..
|
6
|
-
from ..
|
5
|
+
from ..data import DataObject
|
6
|
+
from ..models.error import *
|
7
|
+
from ..contracts.error import Error as ErrorContract
|
7
8
|
|
8
9
|
|
9
10
|
# *** data
|
10
11
|
|
11
|
-
# ** data: error_message_data
|
12
|
-
class ErrorMessageData(ErrorMessage, DataObject):
|
13
|
-
'''
|
14
|
-
A data representation of an error message object.
|
15
|
-
'''
|
16
|
-
|
17
|
-
class Options():
|
18
|
-
serialize_when_none = False
|
19
|
-
roles = {
|
20
|
-
'to_data': DataObject.allow(),
|
21
|
-
'to_model': DataObject.allow()
|
22
|
-
}
|
23
|
-
|
24
|
-
|
25
12
|
# ** data: error_data
|
26
13
|
class ErrorData(Error, DataObject):
|
27
14
|
'''
|
@@ -31,13 +18,13 @@ class ErrorData(Error, DataObject):
|
|
31
18
|
class Options():
|
32
19
|
serialize_when_none = False
|
33
20
|
roles = {
|
34
|
-
'to_data': DataObject.deny('id'),
|
35
|
-
'to_model': DataObject.
|
21
|
+
'to_data': DataObject.deny('id', 'message'),
|
22
|
+
'to_model': DataObject.deny('message')
|
36
23
|
}
|
37
24
|
|
38
25
|
# * attribute: message
|
39
26
|
message = ListType(
|
40
|
-
ModelType(
|
27
|
+
ModelType(ErrorMessage),
|
41
28
|
required=True,
|
42
29
|
metadata=dict(
|
43
30
|
description='The error messages.'
|
@@ -58,13 +45,17 @@ class ErrorData(Error, DataObject):
|
|
58
45
|
'''
|
59
46
|
|
60
47
|
# Convert the data object to a primitive dictionary.
|
61
|
-
return
|
62
|
-
|
63
|
-
|
64
|
-
|
48
|
+
return dict(
|
49
|
+
**super().to_primitive(
|
50
|
+
role,
|
51
|
+
**kwargs
|
52
|
+
),
|
53
|
+
message=[msg.to_primitive() for msg in self.message]
|
54
|
+
)
|
55
|
+
|
65
56
|
|
66
57
|
# * method: map
|
67
|
-
def map(self, **kwargs) ->
|
58
|
+
def map(self, **kwargs) -> ErrorContract:
|
68
59
|
'''
|
69
60
|
Maps the error data to an error object.
|
70
61
|
|