tiferet 1.0.0a0__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.
- app/__init__.py +0 -0
- app/clients/__init__.py +0 -0
- app/clients/yaml.py +93 -0
- app/commands/__init__.py +0 -0
- app/commands/container.py +54 -0
- app/commands/error.py +21 -0
- app/commands/feature.py +90 -0
- app/configs/__init__.py +69 -0
- app/configs/app.py +16 -0
- app/configs/container.py +91 -0
- app/contexts/__init__.py +2 -0
- app/contexts/app.py +130 -0
- app/contexts/container.py +167 -0
- app/contexts/env.py +109 -0
- app/contexts/error.py +95 -0
- app/contexts/feature.py +79 -0
- app/contexts/request.py +108 -0
- app/data/__init__.py +4 -0
- app/data/app.py +227 -0
- app/data/container.py +179 -0
- app/data/error.py +99 -0
- app/data/feature.py +132 -0
- app/domain/__init__.py +5 -0
- app/domain/app.py +330 -0
- app/domain/container.py +141 -0
- app/domain/core.py +199 -0
- app/domain/error.py +136 -0
- app/domain/feature.py +176 -0
- app/repos/__init__.py +0 -0
- app/repos/app.py +102 -0
- app/repos/container.py +164 -0
- app/repos/error.py +173 -0
- app/repos/feature.py +169 -0
- app/services/__init__.py +4 -0
- app/services/cli.py +186 -0
- app/services/container.py +44 -0
- tiferet-1.0.0a0.dist-info/LICENSE +28 -0
- tiferet-1.0.0a0.dist-info/METADATA +13 -0
- tiferet-1.0.0a0.dist-info/RECORD +41 -0
- tiferet-1.0.0a0.dist-info/WHEEL +5 -0
- tiferet-1.0.0a0.dist-info/top_level.txt +1 -0
app/data/app.py
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** app
|
4
|
+
from ..configs import *
|
5
|
+
from ..domain import DataObject
|
6
|
+
from ..domain.app import AppDependency, AppInterface, AppRepositoryConfiguration
|
7
|
+
|
8
|
+
|
9
|
+
# *** data
|
10
|
+
|
11
|
+
# ** data: app_dependency_yaml_data
|
12
|
+
class AppDependencyYamlData(AppDependency, DataObject):
|
13
|
+
'''
|
14
|
+
A YAML data representation of an app dependency object.
|
15
|
+
'''
|
16
|
+
|
17
|
+
class Options():
|
18
|
+
'''
|
19
|
+
The options for the app dependency data.
|
20
|
+
'''
|
21
|
+
serialize_when_none = False
|
22
|
+
roles = {
|
23
|
+
'to_model': DataObject.allow(),
|
24
|
+
'to_data.yaml': DataObject.deny('attribute_id')
|
25
|
+
}
|
26
|
+
|
27
|
+
# * method: new
|
28
|
+
@staticmethod
|
29
|
+
def new(**kwargs) -> 'AppDependencyYamlData':
|
30
|
+
'''
|
31
|
+
Initializes a new YAML representation of an AppDependency object.
|
32
|
+
|
33
|
+
:param kwargs: Additional keyword arguments.
|
34
|
+
:type kwargs: dict
|
35
|
+
:return: A new AppDependencyData object.
|
36
|
+
:rtype: AppDependencyData
|
37
|
+
'''
|
38
|
+
|
39
|
+
# Create a new AppDependencyData object.
|
40
|
+
return AppDependencyYamlData(
|
41
|
+
super(AppDependencyYamlData, AppDependencyYamlData).new(
|
42
|
+
**kwargs
|
43
|
+
)
|
44
|
+
)
|
45
|
+
|
46
|
+
# * method: map
|
47
|
+
def map(self, **kwargs) -> AppDependency:
|
48
|
+
'''
|
49
|
+
Maps the app dependency data to an app dependency object.
|
50
|
+
|
51
|
+
:param role: The role for the mapping.
|
52
|
+
:type role: str
|
53
|
+
:param kwargs: Additional keyword arguments.
|
54
|
+
:type kwargs: dict
|
55
|
+
:return: A new app dependency object.
|
56
|
+
:rtype: AppDependency
|
57
|
+
'''
|
58
|
+
|
59
|
+
# Map the app dependency data.
|
60
|
+
return super().map(AppDependency, **kwargs)
|
61
|
+
|
62
|
+
|
63
|
+
# ** data: app_interface_yaml_data
|
64
|
+
class AppInterfaceYamlData(AppInterface, DataObject):
|
65
|
+
'''
|
66
|
+
A data representation of an app interface object.
|
67
|
+
'''
|
68
|
+
|
69
|
+
class Options():
|
70
|
+
'''
|
71
|
+
The options for the app interface data.
|
72
|
+
'''
|
73
|
+
serialize_when_none = False
|
74
|
+
roles = {
|
75
|
+
'to_model': DataObject.allow(),
|
76
|
+
'to_data.yaml': DataObject.deny('id')
|
77
|
+
}
|
78
|
+
|
79
|
+
# attribute: app_context
|
80
|
+
app_context = ModelType(
|
81
|
+
AppDependencyYamlData,
|
82
|
+
required=True,
|
83
|
+
metadata=dict(
|
84
|
+
description='The application context dependency.'
|
85
|
+
),
|
86
|
+
)
|
87
|
+
|
88
|
+
# * attribute: feature_context
|
89
|
+
feature_context = ModelType(
|
90
|
+
AppDependencyYamlData,
|
91
|
+
required=True,
|
92
|
+
metadata=dict(
|
93
|
+
description='The feature context dependency.'
|
94
|
+
),
|
95
|
+
)
|
96
|
+
|
97
|
+
# * attribute: container_context
|
98
|
+
container_context = ModelType(
|
99
|
+
AppDependencyYamlData,
|
100
|
+
required=True,
|
101
|
+
metadata=dict(
|
102
|
+
description='The container context dependency.'
|
103
|
+
),
|
104
|
+
)
|
105
|
+
|
106
|
+
# * attribute: error_context
|
107
|
+
error_context = ModelType(
|
108
|
+
AppDependencyYamlData,
|
109
|
+
required=True,
|
110
|
+
metadata=dict(
|
111
|
+
description='The error context dependency.'
|
112
|
+
),
|
113
|
+
)
|
114
|
+
|
115
|
+
# * attribute: feature_repo
|
116
|
+
feature_repo = ModelType(
|
117
|
+
AppDependencyYamlData,
|
118
|
+
required=True,
|
119
|
+
metadata=dict(
|
120
|
+
description='The feature repository dependency.'
|
121
|
+
),
|
122
|
+
)
|
123
|
+
|
124
|
+
# * attribute: container_repo
|
125
|
+
container_repo = ModelType(
|
126
|
+
AppDependencyYamlData,
|
127
|
+
required=True,
|
128
|
+
metadata=dict(
|
129
|
+
description='The container repository dependency.'
|
130
|
+
),
|
131
|
+
)
|
132
|
+
|
133
|
+
# * attribute: error_repo
|
134
|
+
error_repo = ModelType(
|
135
|
+
AppDependencyYamlData,
|
136
|
+
required=True,
|
137
|
+
metadata=dict(
|
138
|
+
description='The error repository dependency.'
|
139
|
+
),
|
140
|
+
)
|
141
|
+
|
142
|
+
# * method: new
|
143
|
+
@staticmethod
|
144
|
+
def new(**kwargs) -> 'AppInterfaceYamlData':
|
145
|
+
'''
|
146
|
+
Initializes a new YAML representation of an AppInterface object.
|
147
|
+
|
148
|
+
:param kwargs: Additional keyword arguments.
|
149
|
+
:type kwargs: dict
|
150
|
+
:return: A new AppInterfaceData object.
|
151
|
+
:rtype: AppInterfaceData
|
152
|
+
'''
|
153
|
+
|
154
|
+
# Create a new AppInterfaceData object.
|
155
|
+
return AppInterfaceYamlData(
|
156
|
+
super(AppInterfaceYamlData, AppInterfaceYamlData).new(
|
157
|
+
**kwargs
|
158
|
+
)
|
159
|
+
)
|
160
|
+
|
161
|
+
# * method: map
|
162
|
+
def map(self, **kwargs) -> AppInterface:
|
163
|
+
'''
|
164
|
+
Maps the app interface data to an app interface object.
|
165
|
+
|
166
|
+
:param role: The role for the mapping.
|
167
|
+
:type role: str
|
168
|
+
:param kwargs: Additional keyword arguments.
|
169
|
+
:type kwargs: dict
|
170
|
+
:return: A new app interface object.
|
171
|
+
:rtype: AppInterface
|
172
|
+
'''
|
173
|
+
|
174
|
+
# Map the app interface data.
|
175
|
+
return super().map(AppInterface, **kwargs)
|
176
|
+
|
177
|
+
|
178
|
+
# ** data: app_repository_configuration_yaml_data
|
179
|
+
class AppRepositoryConfigurationYamlData(DataObject):
|
180
|
+
'''
|
181
|
+
A YAML data representation of an app repository configuration object.
|
182
|
+
'''
|
183
|
+
|
184
|
+
class Options():
|
185
|
+
'''
|
186
|
+
The options for the app repository configuration data.
|
187
|
+
'''
|
188
|
+
serialize_when_none = False
|
189
|
+
roles = {
|
190
|
+
'to_model': DataObject.allow(),
|
191
|
+
'to_data.yaml': DataObject.allow()
|
192
|
+
}
|
193
|
+
|
194
|
+
# * method: new
|
195
|
+
@staticmethod
|
196
|
+
def new(**kwargs) -> 'AppRepositoryConfigurationYamlData':
|
197
|
+
'''
|
198
|
+
Initializes a new YAML representation of an AppRepositoryConfiguration object.
|
199
|
+
|
200
|
+
:param kwargs: Additional keyword arguments.
|
201
|
+
:type kwargs: dict
|
202
|
+
:return: A new AppRepositoryConfigurationData object.
|
203
|
+
:rtype: AppRepositoryConfigurationData
|
204
|
+
'''
|
205
|
+
|
206
|
+
# Create a new AppRepositoryConfigurationData object.
|
207
|
+
return AppRepositoryConfigurationYamlData(
|
208
|
+
super(AppRepositoryConfigurationYamlData, AppRepositoryConfigurationYamlData).new(
|
209
|
+
**kwargs
|
210
|
+
)
|
211
|
+
)
|
212
|
+
|
213
|
+
# * method: map
|
214
|
+
def map(self, **kwargs) -> AppRepositoryConfiguration:
|
215
|
+
'''
|
216
|
+
Maps the app repository configuration data to an app repository configuration object.
|
217
|
+
|
218
|
+
:param role: The role for the mapping.
|
219
|
+
:type role: str
|
220
|
+
:param kwargs: Additional keyword arguments.
|
221
|
+
:type kwargs: dict
|
222
|
+
:return: A new app repository configuration object.
|
223
|
+
:rtype: AppRepositoryConfiguration
|
224
|
+
'''
|
225
|
+
|
226
|
+
# Map the app repository configuration data.
|
227
|
+
return super().map(AppRepositoryConfiguration, **kwargs)
|
app/data/container.py
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** app
|
4
|
+
from ..configs import *
|
5
|
+
from ..domain import DataObject
|
6
|
+
from ..domain.container import ContainerAttribute, ContainerDependency
|
7
|
+
|
8
|
+
|
9
|
+
# *** data
|
10
|
+
|
11
|
+
# ** data: container_dependency_yaml_data
|
12
|
+
class ContainerDependencyYamlData(ContainerDependency, DataObject):
|
13
|
+
'''
|
14
|
+
A data representation of a container dependency object.
|
15
|
+
'''
|
16
|
+
|
17
|
+
class Options():
|
18
|
+
'''
|
19
|
+
The options for the container dependency data.
|
20
|
+
'''
|
21
|
+
|
22
|
+
serialize_when_none = False
|
23
|
+
roles = {
|
24
|
+
'to_model': DataObject.allow(),
|
25
|
+
'to_data.yaml': DataObject.deny('flag')
|
26
|
+
}
|
27
|
+
|
28
|
+
# * attribute: flag
|
29
|
+
flag = StringType(
|
30
|
+
metadata=dict(
|
31
|
+
description='The flag is no longer required due to the YAML format.'
|
32
|
+
),
|
33
|
+
)
|
34
|
+
|
35
|
+
# * attribute: parameters
|
36
|
+
parameters = DictType(
|
37
|
+
StringType,
|
38
|
+
default={},
|
39
|
+
serialize_name='params',
|
40
|
+
deserialize_from=['params'],
|
41
|
+
metadata=dict(
|
42
|
+
description='The parameters need to now account for new data names in the YAML format.'
|
43
|
+
),
|
44
|
+
)
|
45
|
+
|
46
|
+
# * method: map
|
47
|
+
def map(self, **kwargs) -> ContainerDependency:
|
48
|
+
'''
|
49
|
+
Maps the container dependency data to a container dependency object.
|
50
|
+
|
51
|
+
:param role: The role for the mapping.
|
52
|
+
:type role: str
|
53
|
+
:return: A new container dependency object.
|
54
|
+
'''
|
55
|
+
|
56
|
+
# Map to the container dependency object.
|
57
|
+
return super().map(ContainerDependency, **kwargs)
|
58
|
+
|
59
|
+
# * method: new
|
60
|
+
@staticmethod
|
61
|
+
def new(**kwargs) -> 'ContainerDependencyYamlData':
|
62
|
+
'''
|
63
|
+
Initializes a new ContainerDependencyData object from YAML data.
|
64
|
+
|
65
|
+
:param kwargs: Additional keyword arguments.
|
66
|
+
:type kwargs: dict
|
67
|
+
:return: A new ContainerDependencyData object.
|
68
|
+
:rtype: ContainerDependencyYamlData
|
69
|
+
'''
|
70
|
+
|
71
|
+
# Create a new ContainerDependencyYamlData object.
|
72
|
+
data = ContainerDependencyYamlData(dict(
|
73
|
+
**kwargs,
|
74
|
+
), strict=False)
|
75
|
+
|
76
|
+
# Validate and return the object.
|
77
|
+
data.validate()
|
78
|
+
return data
|
79
|
+
|
80
|
+
# * method: from_model
|
81
|
+
@staticmethod
|
82
|
+
def from_model(model: ContainerDependency, **kwargs) -> 'ContainerDependencyYamlData':
|
83
|
+
'''
|
84
|
+
Initializes a new ContainerDependencyData object from a model object.
|
85
|
+
|
86
|
+
:param model: The container dependency model object.
|
87
|
+
:type model: ContainerDependency
|
88
|
+
:param kwargs: Additional keyword arguments.
|
89
|
+
:type kwargs: dict
|
90
|
+
'''
|
91
|
+
|
92
|
+
# Create and return a new ContainerDependencyData object.
|
93
|
+
return ContainerDependencyYamlData.new(
|
94
|
+
**model.to_primitive(),
|
95
|
+
**kwargs,
|
96
|
+
)
|
97
|
+
|
98
|
+
|
99
|
+
# ** data: container_attribute_yaml_data
|
100
|
+
class ContainerAttributeYamlData(ContainerAttribute, DataObject):
|
101
|
+
'''
|
102
|
+
A data representation of a container attribute object.
|
103
|
+
'''
|
104
|
+
|
105
|
+
class Options():
|
106
|
+
'''
|
107
|
+
The options for the container attribute data.
|
108
|
+
'''
|
109
|
+
|
110
|
+
serialize_when_none = False
|
111
|
+
roles = {
|
112
|
+
'to_model': DataObject.allow(),
|
113
|
+
'to_data.yaml': DataObject.deny('id')
|
114
|
+
}
|
115
|
+
|
116
|
+
# * attribute: dependencies
|
117
|
+
dependencies = DictType(
|
118
|
+
ModelType(ContainerDependencyYamlData),
|
119
|
+
default=[],
|
120
|
+
serialize_name='deps',
|
121
|
+
deserialize_from=['deps', 'dependencies'],
|
122
|
+
metadata=dict(
|
123
|
+
description='The dependencies are now a key-value pair keyed by the flags.'
|
124
|
+
),
|
125
|
+
)
|
126
|
+
|
127
|
+
# * method: map
|
128
|
+
def map(self, **kwargs) -> ContainerAttribute:
|
129
|
+
'''
|
130
|
+
Maps the container attribute data to a container attribute object.
|
131
|
+
|
132
|
+
:param kwargs: Additional keyword arguments.
|
133
|
+
:type kwargs: dict
|
134
|
+
'''
|
135
|
+
|
136
|
+
# Map to the container attribute object with the dependencies.
|
137
|
+
return super().map(ContainerAttribute,
|
138
|
+
dependencies=[dep.map(flag=flag) for flag, dep in self.dependencies.items()],
|
139
|
+
**kwargs)
|
140
|
+
|
141
|
+
# * method: new
|
142
|
+
@staticmethod
|
143
|
+
def new(**kwargs) -> 'ContainerAttributeYamlData':
|
144
|
+
'''
|
145
|
+
Initializes a new ContainerAttributeData object from YAML data.
|
146
|
+
|
147
|
+
:param kwargs: Additional keyword arguments.
|
148
|
+
:type kwargs: dict
|
149
|
+
'''
|
150
|
+
|
151
|
+
# Create a new ContainerAttributeData object.
|
152
|
+
data = ContainerAttributeYamlData(dict(
|
153
|
+
**kwargs,
|
154
|
+
), strict=False)
|
155
|
+
|
156
|
+
|
157
|
+
# Validate and return the object.
|
158
|
+
data.validate()
|
159
|
+
return data
|
160
|
+
|
161
|
+
# * method: from_model
|
162
|
+
@staticmethod
|
163
|
+
def from_model(model: ContainerAttribute, **kwargs) -> 'ContainerAttributeYamlData':
|
164
|
+
'''
|
165
|
+
Initializes a new ContainerAttributeData object from a model object.
|
166
|
+
|
167
|
+
:param model: The container attribute model object.
|
168
|
+
:type model: ContainerAttribute
|
169
|
+
:param kwargs: Additional keyword arguments.
|
170
|
+
:type kwargs: dict
|
171
|
+
'''
|
172
|
+
|
173
|
+
# Create a new ContainerAttributeData object.
|
174
|
+
return ContainerAttributeYamlData.new(
|
175
|
+
id=model.id,
|
176
|
+
type=model.type,
|
177
|
+
dependencies = {dep.flag: dep for dep in model.dependencies},
|
178
|
+
)
|
179
|
+
|
app/data/error.py
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** app
|
4
|
+
from ..configs import *
|
5
|
+
from ..domain import DataObject
|
6
|
+
from ..domain.error import Error, ErrorMessage
|
7
|
+
|
8
|
+
|
9
|
+
# *** data
|
10
|
+
|
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.yaml': DataObject.allow('id'),
|
21
|
+
'to_object.yaml': DataObject.allow()
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
# ** data: error_data
|
26
|
+
class ErrorData(Error, DataObject):
|
27
|
+
'''
|
28
|
+
A data representation of an error object.
|
29
|
+
'''
|
30
|
+
|
31
|
+
class Options():
|
32
|
+
serialize_when_none = False
|
33
|
+
roles = {
|
34
|
+
'to_data.yaml': DataObject.deny('id'),
|
35
|
+
'to_object.yaml': DataObject.allow()
|
36
|
+
}
|
37
|
+
|
38
|
+
# * attribute: message
|
39
|
+
message = ListType(
|
40
|
+
ModelType(ErrorMessageData),
|
41
|
+
required=True,
|
42
|
+
metadata=dict(
|
43
|
+
description='The error messages.'
|
44
|
+
)
|
45
|
+
)
|
46
|
+
|
47
|
+
# * method: map
|
48
|
+
def map(self, role: str = 'to_object.yaml', **kwargs):
|
49
|
+
'''
|
50
|
+
Maps the error data to an error object.
|
51
|
+
|
52
|
+
:param role: The role for the mapping.
|
53
|
+
:type role: str
|
54
|
+
:param kwargs: Additional keyword arguments.
|
55
|
+
:type kwargs: dict
|
56
|
+
:return: A new error object.
|
57
|
+
:rtype: Error
|
58
|
+
'''
|
59
|
+
|
60
|
+
# Map the error messages.
|
61
|
+
return super().map(Error, role, **kwargs)
|
62
|
+
|
63
|
+
# * method: new
|
64
|
+
@staticmethod
|
65
|
+
def new(**kwargs) -> 'ErrorData':
|
66
|
+
'''
|
67
|
+
Creates a new ErrorData object.
|
68
|
+
|
69
|
+
:param kwargs: Additional keyword arguments.
|
70
|
+
:type kwargs: dict
|
71
|
+
:return: A new ErrorData object.
|
72
|
+
:rtype: ErrorData
|
73
|
+
'''
|
74
|
+
|
75
|
+
# Create a new ErrorData object.
|
76
|
+
return ErrorData(
|
77
|
+
super(ErrorData, ErrorData).new(**kwargs)
|
78
|
+
)
|
79
|
+
|
80
|
+
# * method: from_yaml_data
|
81
|
+
|
82
|
+
@staticmethod
|
83
|
+
def from_yaml_data(id: str, **kwargs):
|
84
|
+
'''
|
85
|
+
Initializes a new ErrorData object from yaml data.
|
86
|
+
|
87
|
+
:param id: The unique identifier for the error.
|
88
|
+
:type id: str
|
89
|
+
:param kwargs: Additional keyword arguments.
|
90
|
+
:type kwargs: dict
|
91
|
+
:return: A new ErrorData object.
|
92
|
+
:rtype: ErrorData
|
93
|
+
'''
|
94
|
+
|
95
|
+
# Create a new ErrorData object.
|
96
|
+
return ErrorData.new(
|
97
|
+
id=id,
|
98
|
+
**kwargs
|
99
|
+
)
|
app/data/feature.py
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
|
2
|
+
from schematics.types.serializable import serializable
|
3
|
+
|
4
|
+
from ..domain import *
|
5
|
+
from ..domain.feature import Feature, FeatureCommand
|
6
|
+
|
7
|
+
|
8
|
+
class FeatureCommandData(FeatureCommand, DataObject):
|
9
|
+
'''
|
10
|
+
A data representation of a feature handler.
|
11
|
+
'''
|
12
|
+
|
13
|
+
class Options():
|
14
|
+
'''
|
15
|
+
The default options for the feature handler data.
|
16
|
+
'''
|
17
|
+
|
18
|
+
# Set the serialize when none flag to false.
|
19
|
+
serialize_when_none = False
|
20
|
+
|
21
|
+
# Define the roles for the feature handler data.
|
22
|
+
roles = {
|
23
|
+
'to_object.yaml': DataObject.allow(),
|
24
|
+
'to_data.yaml': DataObject.allow()
|
25
|
+
}
|
26
|
+
|
27
|
+
def map(self, role: str = 'to_object', **kwargs) -> FeatureCommand:
|
28
|
+
'''
|
29
|
+
Maps the feature handler data to a feature handler object.
|
30
|
+
|
31
|
+
:param role: The role for the mapping.
|
32
|
+
:type role: str
|
33
|
+
:param kwargs: Additional keyword arguments.
|
34
|
+
:type kwargs: dict
|
35
|
+
:return: A new feature handler object.
|
36
|
+
:rtype: f.FeatureCommand
|
37
|
+
'''
|
38
|
+
return super().map(FeatureCommand, role, **kwargs)
|
39
|
+
|
40
|
+
|
41
|
+
class FeatureData(Feature, DataObject):
|
42
|
+
'''
|
43
|
+
A data representation of a feature.
|
44
|
+
'''
|
45
|
+
|
46
|
+
class Options():
|
47
|
+
'''
|
48
|
+
The default options for the feature data.
|
49
|
+
'''
|
50
|
+
|
51
|
+
# Set the serialize when none flag to false.
|
52
|
+
serialize_when_none = False
|
53
|
+
|
54
|
+
# Define the roles for the feature data.
|
55
|
+
roles = {
|
56
|
+
'to_object.yaml': DataObject.deny('feature_key'),
|
57
|
+
'to_data.yaml': DataObject.deny('feature_key', 'group_id', 'id')
|
58
|
+
}
|
59
|
+
|
60
|
+
commands = t.ListType(t.ModelType(FeatureCommandData),
|
61
|
+
deserialize_from=['handlers', 'functions', 'commands'],)
|
62
|
+
|
63
|
+
@serializable
|
64
|
+
def feature_key(self):
|
65
|
+
'''
|
66
|
+
Gets the feature key.
|
67
|
+
'''
|
68
|
+
|
69
|
+
# Return the feature key.
|
70
|
+
return self.id.split('.')[-1]
|
71
|
+
|
72
|
+
def map(self, role: str = 'to_object.yaml', **kwargs) -> Feature:
|
73
|
+
'''
|
74
|
+
Maps the feature data to a feature object.
|
75
|
+
|
76
|
+
:param role: The role for the mapping.
|
77
|
+
:type role: str
|
78
|
+
:param kwargs: Additional keyword arguments.
|
79
|
+
:type kwargs: dict
|
80
|
+
:return: A new feature object.
|
81
|
+
:rtype: f.Feature
|
82
|
+
'''
|
83
|
+
|
84
|
+
# Map the feature data to a feature object.
|
85
|
+
return super().map(Feature, role, **kwargs)
|
86
|
+
|
87
|
+
@staticmethod
|
88
|
+
def new(**kwargs) -> 'FeatureData':
|
89
|
+
'''
|
90
|
+
Initializes a new FeatureData object from a Feature object.
|
91
|
+
|
92
|
+
:param kwargs: Additional keyword arguments.
|
93
|
+
:type kwargs: dict
|
94
|
+
:return: A new FeatureData object.
|
95
|
+
:rtype: FeatureData
|
96
|
+
'''
|
97
|
+
|
98
|
+
# Create a new FeatureData object.
|
99
|
+
_data = FeatureData(
|
100
|
+
dict(**kwargs,),
|
101
|
+
strict=False
|
102
|
+
)
|
103
|
+
|
104
|
+
# Validate and return the new FeatureData object.
|
105
|
+
_data.validate()
|
106
|
+
return _data
|
107
|
+
|
108
|
+
@staticmethod
|
109
|
+
def from_yaml_data(id: str, group_id: str, **kwargs) -> 'FeatureData':
|
110
|
+
'''
|
111
|
+
Initializes a new FeatureData object from yaml data.
|
112
|
+
|
113
|
+
:param id: The feature id.
|
114
|
+
:type id: str
|
115
|
+
:param group_id: The context group id.
|
116
|
+
:type group_id: str
|
117
|
+
:param kwargs: Additional keyword arguments.
|
118
|
+
:type kwargs: dict
|
119
|
+
:return: A new FeatureData object.
|
120
|
+
:rtype: FeatureData
|
121
|
+
'''
|
122
|
+
|
123
|
+
# Create a new FeatureData object.
|
124
|
+
_data = FeatureData(
|
125
|
+
dict(**kwargs,
|
126
|
+
id=id, group_id=group_id
|
127
|
+
),
|
128
|
+
strict=False)
|
129
|
+
|
130
|
+
# Validate and return the new FeatureData object.
|
131
|
+
_data.validate()
|
132
|
+
return _data
|