tiferet 1.0.0a8__py3-none-any.whl → 1.0.0a10__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 +5 -1
- tiferet/clients/yaml.py +14 -5
- tiferet/contexts/__init__.py +7 -3
- tiferet/contexts/app.py +13 -13
- tiferet/contexts/container.py +8 -4
- tiferet/contexts/error.py +8 -9
- tiferet/contexts/feature.py +16 -9
- tiferet/contexts/request.py +6 -4
- tiferet/data/__init__.py +2 -1
- tiferet/data/app.py +107 -80
- tiferet/data/container.py +61 -27
- tiferet/data/error.py +32 -12
- tiferet/data/feature.py +17 -41
- tiferet/domain/__init__.py +2 -2
- tiferet/domain/app.py +0 -58
- tiferet/domain/container.py +26 -26
- tiferet/domain/core.py +43 -5
- tiferet/domain/error.py +18 -0
- tiferet/domain/feature.py +11 -3
- tiferet/repos/__init__.py +7 -0
- tiferet/repos/app.py +8 -4
- tiferet/repos/container.py +5 -46
- tiferet/repos/error.py +8 -8
- tiferet/repos/feature.py +6 -42
- tiferet/services/__init__.py +5 -1
- tiferet/services/app.py +52 -0
- {tiferet-1.0.0a8.dist-info → tiferet-1.0.0a10.dist-info}/METADATA +4 -5
- tiferet-1.0.0a10.dist-info/RECORD +38 -0
- {tiferet-1.0.0a8.dist-info → tiferet-1.0.0a10.dist-info}/WHEEL +1 -1
- tiferet/configs/app.py +0 -16
- tiferet/contexts/env.py +0 -122
- tiferet-1.0.0a8.dist-info/RECORD +0 -39
- {tiferet-1.0.0a8.dist-info → tiferet-1.0.0a10.dist-info}/LICENSE +0 -0
- {tiferet-1.0.0a8.dist-info → tiferet-1.0.0a10.dist-info}/top_level.txt +0 -0
tiferet/repos/app.py
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# ** app
|
4
4
|
from ..domain.app import AppInterface
|
5
5
|
from ..data.app import AppInterfaceYamlData
|
6
|
-
from ..clients import
|
6
|
+
from ..clients import yaml_client
|
7
7
|
|
8
8
|
|
9
9
|
# *** repository
|
@@ -72,7 +72,7 @@ class YamlProxy(object):
|
|
72
72
|
interfaces = yaml_client.load(
|
73
73
|
self.config_file,
|
74
74
|
create_data=lambda data: [
|
75
|
-
AppInterfaceYamlData.
|
75
|
+
AppInterfaceYamlData.from_data(
|
76
76
|
id=interface_id,
|
77
77
|
**record
|
78
78
|
).map() for interface_id, record in data.items()],
|
@@ -95,9 +95,13 @@ class YamlProxy(object):
|
|
95
95
|
# Load the app interface data from the yaml configuration file.
|
96
96
|
_data: AppInterface = yaml_client.load(
|
97
97
|
self.config_file,
|
98
|
-
create_data=lambda data: AppInterfaceYamlData.
|
98
|
+
create_data=lambda data: AppInterfaceYamlData.from_data(
|
99
99
|
id=id, **data),
|
100
100
|
start_node=lambda data: data.get('interfaces').get(id))
|
101
101
|
|
102
102
|
# Return the app interface object.
|
103
|
-
return
|
103
|
+
# If the data is None, return None.
|
104
|
+
try:
|
105
|
+
return _data.map()
|
106
|
+
except AttributeError:
|
107
|
+
return None
|
tiferet/repos/container.py
CHANGED
@@ -51,18 +51,6 @@ class ContainerRepository(object):
|
|
51
51
|
# Not implemented.
|
52
52
|
raise NotImplementedError()
|
53
53
|
|
54
|
-
# * method: save_attribute
|
55
|
-
def save_attribute(self, attribute: ContainerAttribute):
|
56
|
-
'''
|
57
|
-
Save the container attribute.
|
58
|
-
|
59
|
-
:param attribute: The container attribute.
|
60
|
-
:type attribute: ContainerAttribute
|
61
|
-
'''
|
62
|
-
|
63
|
-
# Not implemented.
|
64
|
-
raise NotImplementedError
|
65
|
-
|
66
54
|
|
67
55
|
# ** proxy: yaml_proxy
|
68
56
|
class YamlProxy(ContainerRepository):
|
@@ -71,27 +59,17 @@ class YamlProxy(ContainerRepository):
|
|
71
59
|
'''
|
72
60
|
|
73
61
|
# * init
|
74
|
-
def __init__(self, container_config_file: str
|
62
|
+
def __init__(self, container_config_file: str):
|
75
63
|
'''
|
76
64
|
Initialize the yaml proxy.
|
77
65
|
|
78
66
|
:param container_config_file: The YAML file path for the container configuration.
|
79
67
|
:type container_config_file: str
|
80
|
-
:param read_role: The read role for the yaml proxy.
|
81
|
-
:type read_role: str
|
82
|
-
:param write_role: The write role for the yaml proxy.
|
83
|
-
:type write_role: str
|
84
68
|
'''
|
85
69
|
|
86
70
|
# Set the container configuration file.
|
87
71
|
self.config_file = container_config_file
|
88
72
|
|
89
|
-
# Set the read role.
|
90
|
-
self.read_role = read_role
|
91
|
-
|
92
|
-
# Set the write role.
|
93
|
-
self.write_role = write_role
|
94
|
-
|
95
73
|
# * method: get_attribute
|
96
74
|
def get_attribute(self, attribute_id: str, type: str) -> ContainerAttribute:
|
97
75
|
'''
|
@@ -108,7 +86,7 @@ class YamlProxy(ContainerRepository):
|
|
108
86
|
# Load the attribute data from the yaml configuration file.
|
109
87
|
data = yaml_client.load(
|
110
88
|
self.config_file,
|
111
|
-
create_data=lambda data: ContainerAttributeYamlData.
|
89
|
+
create_data=lambda data: ContainerAttributeYamlData.from_data(
|
112
90
|
id=attribute_id, **data),
|
113
91
|
start_node=lambda data: data.get('attrs').get(attribute_id),
|
114
92
|
)
|
@@ -118,7 +96,7 @@ class YamlProxy(ContainerRepository):
|
|
118
96
|
return None
|
119
97
|
|
120
98
|
# Return the attribute.
|
121
|
-
return data.map(
|
99
|
+
return data.map()
|
122
100
|
|
123
101
|
# * method: list_all
|
124
102
|
def list_all(self) -> Tuple[List[ContainerAttribute], Dict[str, str]]:
|
@@ -133,32 +111,13 @@ class YamlProxy(ContainerRepository):
|
|
133
111
|
attr_data, consts = yaml_client.load(
|
134
112
|
self.config_file,
|
135
113
|
create_data=lambda data: (
|
136
|
-
[ContainerAttributeYamlData.
|
114
|
+
[ContainerAttributeYamlData.from_data(id=id, **attr_data) for id, attr_data in data.get('attrs', {}).items()],
|
137
115
|
data.get('const', {}),
|
138
116
|
),
|
139
117
|
)
|
140
118
|
|
141
119
|
# Return the list of container attributes.
|
142
120
|
return (
|
143
|
-
[data.map(
|
121
|
+
[data.map() for data in attr_data],
|
144
122
|
consts
|
145
123
|
)
|
146
|
-
|
147
|
-
# * method: save_attribute
|
148
|
-
def save_attribute(self, attribute: ContainerAttribute):
|
149
|
-
'''
|
150
|
-
Save the attribute to the yaml file.
|
151
|
-
|
152
|
-
:param attribute: The attribute to save.
|
153
|
-
:type attribute: ContainerAttribute
|
154
|
-
'''
|
155
|
-
|
156
|
-
# Create a new container attribute data object.
|
157
|
-
data = ContainerAttributeYamlData.from_model(attribute)
|
158
|
-
|
159
|
-
# Update the attribute data.
|
160
|
-
yaml_client.save(
|
161
|
-
self.config_file,
|
162
|
-
data.to_primitive(role=self.write_role),
|
163
|
-
f'container/attrs/{attribute.id}'
|
164
|
-
)
|
tiferet/repos/error.py
CHANGED
@@ -106,7 +106,7 @@ class YamlProxy(ErrorRepository):
|
|
106
106
|
# Load the error data from the yaml configuration file.
|
107
107
|
data: List[ErrorData] = yaml_client.load(
|
108
108
|
self.config_file,
|
109
|
-
create_data=lambda data: ErrorData.
|
109
|
+
create_data=lambda data: ErrorData.from_data(
|
110
110
|
id=id, **data),
|
111
111
|
start_node=lambda data: data.get('errors').get(id))
|
112
112
|
|
@@ -127,12 +127,12 @@ class YamlProxy(ErrorRepository):
|
|
127
127
|
# Load the error data from the yaml configuration file.
|
128
128
|
_data: ErrorData = yaml_client.load(
|
129
129
|
self.config_file,
|
130
|
-
create_data=lambda data: ErrorData.
|
130
|
+
create_data=lambda data: ErrorData.from_data(
|
131
131
|
id=id, **data),
|
132
132
|
start_node=lambda data: data.get('errors').get(id))
|
133
133
|
|
134
134
|
# Return the error object.
|
135
|
-
return _data.map(
|
135
|
+
return _data.map()
|
136
136
|
|
137
137
|
# * method: list
|
138
138
|
def list(self) -> List[Error]:
|
@@ -146,12 +146,12 @@ class YamlProxy(ErrorRepository):
|
|
146
146
|
# Load the error data from the yaml configuration file.
|
147
147
|
_data: Dict[str, ErrorData] = yaml_client.load(
|
148
148
|
self.config_file,
|
149
|
-
create_data=lambda data: {id: ErrorData.
|
149
|
+
create_data=lambda data: {id: ErrorData.from_data(
|
150
150
|
id=id, **error_data) for id, error_data in data.items()},
|
151
151
|
start_node=lambda data: data.get('errors'))
|
152
152
|
|
153
153
|
# Return the error object.
|
154
|
-
return [data.map(
|
154
|
+
return [data.map() for data in _data.values()]
|
155
155
|
|
156
156
|
# * method: save
|
157
157
|
def save(self, error: Error):
|
@@ -163,11 +163,11 @@ class YamlProxy(ErrorRepository):
|
|
163
163
|
'''
|
164
164
|
|
165
165
|
# Create updated error data.
|
166
|
-
error_data = ErrorData.
|
166
|
+
error_data = ErrorData.from_model(ErrorData, error)
|
167
167
|
|
168
168
|
# Update the error data.
|
169
169
|
yaml_client.save(
|
170
|
-
|
171
|
-
data=error_data,
|
170
|
+
yaml_file=self.config_file,
|
171
|
+
data=error_data.to_primitive(),
|
172
172
|
data_save_path=f'errors/{error.name}',
|
173
173
|
)
|
tiferet/repos/feature.py
CHANGED
@@ -55,20 +55,9 @@ class FeatureRepository(object):
|
|
55
55
|
:rtype: list
|
56
56
|
'''
|
57
57
|
|
58
|
-
# Not implemented.
|
59
|
-
raise NotImplementedError
|
60
|
-
|
61
|
-
# * method: save
|
62
|
-
def save(self, feature: Feature):
|
63
|
-
'''
|
64
|
-
Save the feature.
|
65
|
-
|
66
|
-
:param feature: The feature object.
|
67
|
-
:type feature: f.Feature
|
68
|
-
'''
|
69
|
-
|
70
58
|
# Not implemented.
|
71
59
|
raise NotImplementedError()
|
60
|
+
|
72
61
|
|
73
62
|
# ** repository: yaml_proxy
|
74
63
|
class YamlProxy(FeatureRepository):
|
@@ -115,18 +104,14 @@ class YamlProxy(FeatureRepository):
|
|
115
104
|
:return: The feature object.
|
116
105
|
'''
|
117
106
|
|
118
|
-
# Get context group and feature key from the id.
|
119
|
-
group_id, feature_key = id.split('.')
|
120
|
-
|
121
107
|
# Load feature data from yaml.
|
122
108
|
_data: FeatureData = yaml_client.load(
|
123
109
|
self.config_file,
|
124
|
-
create_data=lambda data: FeatureData.
|
110
|
+
create_data=lambda data: FeatureData.from_data(
|
125
111
|
id=id,
|
126
|
-
group_id=group_id,
|
127
112
|
**data
|
128
113
|
),
|
129
|
-
start_node=lambda data: data.get('features').get(
|
114
|
+
start_node=lambda data: data.get('features').get(id)
|
130
115
|
)
|
131
116
|
|
132
117
|
# Return None if feature data is not found.
|
@@ -134,7 +119,7 @@ class YamlProxy(FeatureRepository):
|
|
134
119
|
return None
|
135
120
|
|
136
121
|
# Return feature.
|
137
|
-
return _data.map(
|
122
|
+
return _data.map()
|
138
123
|
|
139
124
|
# * method: list
|
140
125
|
def list(self, group_id: str = None) -> List[Feature]:
|
@@ -150,7 +135,7 @@ class YamlProxy(FeatureRepository):
|
|
150
135
|
# Load all feature data from yaml.
|
151
136
|
features = yaml_client.load(
|
152
137
|
self.config_file,
|
153
|
-
create_data=lambda data: [FeatureData.
|
138
|
+
create_data=lambda data: [FeatureData.from_data(
|
154
139
|
id=id,
|
155
140
|
**feature_data
|
156
141
|
) for id, feature_data in data.items()],
|
@@ -162,26 +147,5 @@ class YamlProxy(FeatureRepository):
|
|
162
147
|
features = [feature for feature in features if feature.group_id == group_id]
|
163
148
|
|
164
149
|
# Return the list of features.
|
165
|
-
return [feature.map(
|
166
|
-
|
167
|
-
# * method: save
|
168
|
-
def save(self, feature: Feature):
|
169
|
-
'''
|
170
|
-
Save the feature.
|
171
|
-
|
172
|
-
:param feature: The feature object.
|
173
|
-
:type feature: f.Feature
|
174
|
-
'''
|
175
|
-
|
176
|
-
# Create updated feature data.
|
177
|
-
feature_data = FeatureData.new(**feature.to_primitive())
|
178
|
-
|
179
|
-
# Update the feature data.
|
180
|
-
yaml_client.save(
|
181
|
-
self.config_file,
|
182
|
-
data=feature_data,
|
183
|
-
data_save_path=f'features/{feature.group_id}.{feature_data.feature_key}'
|
184
|
-
)
|
150
|
+
return [feature.map() for feature in features]
|
185
151
|
|
186
|
-
# Return the updated feature object.
|
187
|
-
return feature_data.map('to_object.yaml')
|
tiferet/services/__init__.py
CHANGED
tiferet/services/app.py
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# *** imports
|
2
|
+
|
3
|
+
# ** core
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
# ** app
|
7
|
+
from ..domain import AppInterface
|
8
|
+
from ..repos.app import AppRepository
|
9
|
+
from . import container_service
|
10
|
+
|
11
|
+
|
12
|
+
# *** functions
|
13
|
+
|
14
|
+
# ** function: load_app_context
|
15
|
+
def load_app_context(interface_id: str, app_repo: AppRepository) -> Any:
|
16
|
+
'''
|
17
|
+
Load the app context.
|
18
|
+
|
19
|
+
:param container: The app container.
|
20
|
+
:type container: AppContainer
|
21
|
+
:return: The app context.
|
22
|
+
:rtype: Any
|
23
|
+
'''
|
24
|
+
|
25
|
+
# Get the app interface.
|
26
|
+
app_interface: AppInterface = app_repo.get_interface(interface_id)
|
27
|
+
|
28
|
+
# Get the default dependencies for the app interface.
|
29
|
+
app_context = app_interface.get_dependency('app_context')
|
30
|
+
dependencies = dict(
|
31
|
+
interface_id=app_interface.id,
|
32
|
+
app_name=app_interface.name,
|
33
|
+
feature_flag=app_interface.feature_flag,
|
34
|
+
data_flag=app_interface.data_flag,
|
35
|
+
app_context=container_service.import_dependency(
|
36
|
+
**app_context.to_primitive()
|
37
|
+
),
|
38
|
+
**app_interface.constants
|
39
|
+
)
|
40
|
+
|
41
|
+
# Import the dependencies.
|
42
|
+
for dep in app_interface.dependencies:
|
43
|
+
dependencies[dep.attribute_id] = container_service.import_dependency(dep.module_path, dep.class_name)
|
44
|
+
|
45
|
+
# Create the injector from the dependencies, constants, and the app interface.
|
46
|
+
injector = container_service.create_injector(
|
47
|
+
app_interface.id,
|
48
|
+
**dependencies
|
49
|
+
)
|
50
|
+
|
51
|
+
# Return the app context.
|
52
|
+
return getattr(injector, 'app_context')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: tiferet
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.0a10
|
4
4
|
Summary: A multi-purpose application framework embodying beauty in form.
|
5
5
|
Home-page: https://github.com/greatstrength/app
|
6
6
|
Download-URL: https://github.com/greatstrength/app
|
@@ -8,7 +8,6 @@ Author: Andrew Shatz
|
|
8
8
|
Author-email: andrew@greatstrength.me
|
9
9
|
License: BSD 3
|
10
10
|
License-File: LICENSE
|
11
|
-
Requires-Dist: schematics
|
12
|
-
Requires-Dist: pyyaml
|
13
|
-
Requires-Dist: dependencies
|
14
|
-
|
11
|
+
Requires-Dist: schematics>=2.1.1
|
12
|
+
Requires-Dist: pyyaml>=6.0.1
|
13
|
+
Requires-Dist: dependencies>=7.7.0
|
@@ -0,0 +1,38 @@
|
|
1
|
+
tiferet/__init__.py,sha256=1CDYADhNKmHqE4yYf7RgcQcNQm34FTRR2w4WTzbm2Rk,70
|
2
|
+
tiferet/clients/__init__.py,sha256=hSa_PgXM2jw9iVRrJH_SQUlSVISK-T4tTfgRKnXKkzA,33
|
3
|
+
tiferet/clients/yaml.py,sha256=790LB7CpaMow_Ng8zB6jGmJnoqz8xjMYbfDLeMd4o3Q,2816
|
4
|
+
tiferet/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
+
tiferet/commands/container.py,sha256=L2IKJqEbRglw_LC144oYAkARr2Rixj8IFuC6Ro1jAqA,1789
|
6
|
+
tiferet/commands/error.py,sha256=ixMYH0yrEWlMAVGDSRke3IGoWaOShfmiXntrUC2b3wY,573
|
7
|
+
tiferet/commands/feature.py,sha256=tXa-MDf14ByIJqwQFeSUu2QLUjHPdsyvFNhj1XeaQVk,2507
|
8
|
+
tiferet/configs/__init__.py,sha256=NfT6XFNcJznOLXjMuNmj3XeaOPVWwbc-N4kVWaVjuD0,845
|
9
|
+
tiferet/contexts/__init__.py,sha256=HjI-9n29mFxN6ILSa3LBhLSVPRe-1V36ffQXSP9RavM,204
|
10
|
+
tiferet/contexts/app.py,sha256=9VxWliIX_Y0Y8CZXQzYLgzN89MabkFzkW2e7-3P5KrQ,3781
|
11
|
+
tiferet/contexts/container.py,sha256=WXg_PsZQOIfZWW8rNj0NTTg3bLJUjIRGhIGgENzJfxE,5175
|
12
|
+
tiferet/contexts/error.py,sha256=mS72JU7rlxs9yEeDj5ZW3DuJftYqmkyp8DOhzNUwtMw,2562
|
13
|
+
tiferet/contexts/feature.py,sha256=FgHgk3xz3jpQUPynfX7uw9GmhV5wpHRHLtYWvKkkEwE,2979
|
14
|
+
tiferet/contexts/request.py,sha256=EwTyXVYi8z1t1ns_0yDrjY6qICIMPn1UvZpV7ULKReY,2756
|
15
|
+
tiferet/data/__init__.py,sha256=JKaeCw508WY15-etqdFJxPUUJxMxCAi6ASmA472D1_s,93
|
16
|
+
tiferet/data/app.py,sha256=TWWwP0MDpQ-LSKg9166CyPSeI7jjcklIfwBlLW_rT5c,9619
|
17
|
+
tiferet/data/container.py,sha256=o2HnLN1LasqWGP_S1Ub32CrCqYzehlD3dgXizW9XfU8,6154
|
18
|
+
tiferet/data/error.py,sha256=Kllt0w62BAyShdVSwATN0LiVTeQHqkyQAN9_HuFg31Q,2339
|
19
|
+
tiferet/data/feature.py,sha256=cjmm0lkmoFiCs0kyTDLH-OruTxTNJQf4BAkjtFu22Tk,2921
|
20
|
+
tiferet/domain/__init__.py,sha256=U1ul1QPaOlezeQkU8JJ4F-fHUrQMvJMarDIHaByDVr0,210
|
21
|
+
tiferet/domain/app.py,sha256=uRBKpPJa1IrDtnwQRtu2brDZBniFZcdaxOGOfUIN3e0,4808
|
22
|
+
tiferet/domain/container.py,sha256=wjal73hWAs5EvRO9XbrBBfdpV9nq9J89mAPbd4SH4ws,3666
|
23
|
+
tiferet/domain/core.py,sha256=fOZeGxTJLGzY2zgAoSJu6rVJySpv-vCycT-WcEMk8kI,5152
|
24
|
+
tiferet/domain/error.py,sha256=tWoJqg81LtfZfArN5OJRPVaZrAFcET0YUJJs52KHqYA,3853
|
25
|
+
tiferet/domain/feature.py,sha256=drkCfhuIQhT05m61QzKdscaFdP0f-4K4tqO98lzXOjM,4866
|
26
|
+
tiferet/repos/__init__.py,sha256=m6YLp90oqqs0cXQKOrDxudcc8P-AbeJ87a8okgoU7uI,171
|
27
|
+
tiferet/repos/app.py,sha256=S7HM_iH_UkittmTZTO6Dxff9IYjXlE-QjG31X3bPnaA,2886
|
28
|
+
tiferet/repos/container.py,sha256=n9Tz83QETdAocGAT4oKcvllEGwFp069pYqkXs2-KFFk,3519
|
29
|
+
tiferet/repos/error.py,sha256=jDze41uioKwKEkAswkzLubVw-bxsVyeUkJwyeO5Es0E,4245
|
30
|
+
tiferet/repos/feature.py,sha256=GxOV8XHNwz9YY3I8Wch6GaDskvkdi8l1hM9E9fCg1y0,3644
|
31
|
+
tiferet/services/__init__.py,sha256=zB5elAFApNH435JLExPmWxvBmZcCtbAyai-KawUjr4E,101
|
32
|
+
tiferet/services/app.py,sha256=92GvC-Vh8FDZoYMLdgzQ3iS1TVL4uyIErk7NJ4rpYPI,1462
|
33
|
+
tiferet/services/container.py,sha256=ISJhkiNLV--nHbAv6Ajd3ug1cGiyazZoePJOCJu5n_s,1130
|
34
|
+
tiferet-1.0.0a10.dist-info/LICENSE,sha256=e8_GutFM0sxbRlgUaeVsGvJ5uE-KvruLApOzIoHy_zU,1513
|
35
|
+
tiferet-1.0.0a10.dist-info/METADATA,sha256=sy6HMZIH1CaR7AfNqilSRhMlI-keX5clnGBV5rimESw,419
|
36
|
+
tiferet-1.0.0a10.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
37
|
+
tiferet-1.0.0a10.dist-info/top_level.txt,sha256=g19Qw0j_VxPw-fgPF1TMPwbtHjnEhNQs0fa69wJZ6IM,8
|
38
|
+
tiferet-1.0.0a10.dist-info/RECORD,,
|
tiferet/configs/app.py
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# *** imports
|
2
|
-
|
3
|
-
# ** app
|
4
|
-
from ..domain.app import AppRepositoryConfiguration
|
5
|
-
|
6
|
-
|
7
|
-
# *** constants
|
8
|
-
|
9
|
-
# ** constant: APP_REPO
|
10
|
-
APP_REPO = AppRepositoryConfiguration.new(
|
11
|
-
module_path='tiferet.repos.app',
|
12
|
-
class_name='YamlProxy',
|
13
|
-
params=dict(
|
14
|
-
app_config_file='app/configs/app.yml'
|
15
|
-
),
|
16
|
-
)
|
tiferet/contexts/env.py
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
# *** imports
|
2
|
-
|
3
|
-
# ** infra
|
4
|
-
from schematics import Model
|
5
|
-
|
6
|
-
# ** app
|
7
|
-
from .app import AppInterfaceContext
|
8
|
-
from ..services import container_service
|
9
|
-
from ..domain import *
|
10
|
-
from ..repos.app import AppRepository
|
11
|
-
|
12
|
-
|
13
|
-
# *** contexts
|
14
|
-
|
15
|
-
# ** context: environment_context
|
16
|
-
class EnvironmentContext(Model):
|
17
|
-
'''
|
18
|
-
An environment context is a class that is used to create and run the app interface context.
|
19
|
-
'''
|
20
|
-
|
21
|
-
# * attribute: interfaces
|
22
|
-
interfaces = DictType(
|
23
|
-
ModelType(AppInterface),
|
24
|
-
default={},
|
25
|
-
metadata=dict(
|
26
|
-
description='The app interfaces keyed by interface ID.'
|
27
|
-
),
|
28
|
-
)
|
29
|
-
|
30
|
-
# * method: init
|
31
|
-
def __init__(self, **kwargs):
|
32
|
-
'''
|
33
|
-
Initialize the environment context.
|
34
|
-
|
35
|
-
:param kwargs: Additional keyword arguments.
|
36
|
-
:type kwargs: dict
|
37
|
-
'''
|
38
|
-
|
39
|
-
# Load the app repository.
|
40
|
-
app_repo = self.load_app_repo()
|
41
|
-
|
42
|
-
# Load the interface configuration.
|
43
|
-
interfaces = {interface.id: interface for interface in app_repo.list_interfaces()}
|
44
|
-
|
45
|
-
# Set the interfaces.
|
46
|
-
super().__init__(dict(
|
47
|
-
interfaces=interfaces,
|
48
|
-
**kwargs
|
49
|
-
), strict=False)
|
50
|
-
|
51
|
-
# * method: start
|
52
|
-
def start(self, interface_id: str, **kwargs):
|
53
|
-
'''
|
54
|
-
Start the environment context.
|
55
|
-
|
56
|
-
:param kwargs: Additional keyword arguments.
|
57
|
-
:type kwargs: dict
|
58
|
-
'''
|
59
|
-
|
60
|
-
# Load the app context.
|
61
|
-
app_context = self.load_app_context(interface_id)
|
62
|
-
|
63
|
-
# Run the app context.
|
64
|
-
app_context.run(
|
65
|
-
interface_id=interface_id,
|
66
|
-
**kwargs
|
67
|
-
)
|
68
|
-
|
69
|
-
# * method: load_app_repo
|
70
|
-
def load_app_repo(self) -> AppRepository:
|
71
|
-
'''
|
72
|
-
Load the app interface repository.
|
73
|
-
|
74
|
-
:return: The app repository.
|
75
|
-
:rtype: AppRepository
|
76
|
-
'''
|
77
|
-
|
78
|
-
# Load the app repository configuration.
|
79
|
-
from ..configs.app import APP_REPO
|
80
|
-
|
81
|
-
# Return the app repository.
|
82
|
-
return container_service.import_dependency(APP_REPO.module_path, APP_REPO.class_name)(**APP_REPO.params)
|
83
|
-
|
84
|
-
# * method: load_app_context
|
85
|
-
def load_app_context(self, interface_id: str) -> AppInterfaceContext:
|
86
|
-
'''
|
87
|
-
Load the app context.
|
88
|
-
|
89
|
-
:param container: The app container.
|
90
|
-
:type container: AppContainer
|
91
|
-
:return: The app context.
|
92
|
-
:rtype: AppContext
|
93
|
-
'''
|
94
|
-
|
95
|
-
# Get the app interface.
|
96
|
-
app_interface: AppInterface = self.interfaces.get(interface_id)
|
97
|
-
|
98
|
-
# Get the default dependencies for the app interface.
|
99
|
-
app_context = app_interface.get_dependency('app_context')
|
100
|
-
dependencies = dict(
|
101
|
-
interface_id=app_interface.id,
|
102
|
-
app_name=app_interface.name,
|
103
|
-
feature_flag=app_interface.feature_flag,
|
104
|
-
data_flag=app_interface.data_flag,
|
105
|
-
app_context=container_service.import_dependency(
|
106
|
-
**app_context.to_primitive()
|
107
|
-
),
|
108
|
-
**app_interface.constants
|
109
|
-
)
|
110
|
-
|
111
|
-
# Import the dependencies.
|
112
|
-
for dep in app_interface.dependencies:
|
113
|
-
dependencies[dep.attribute_id] = container_service.import_dependency(dep.module_path, dep.class_name)
|
114
|
-
|
115
|
-
# Create the injector from the dependencies, constants, and the app interface.
|
116
|
-
injector = container_service.create_injector(
|
117
|
-
app_interface.id,
|
118
|
-
**dependencies
|
119
|
-
)
|
120
|
-
|
121
|
-
# Return the app context.
|
122
|
-
return getattr(injector, 'app_context')
|
tiferet-1.0.0a8.dist-info/RECORD
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
tiferet/__init__.py,sha256=XtrOOpLk8fjC_CY-UZFmzYQ6Q9mL73D_6scuWpEJXZU,23
|
2
|
-
tiferet/clients/__init__.py,sha256=hSa_PgXM2jw9iVRrJH_SQUlSVISK-T4tTfgRKnXKkzA,33
|
3
|
-
tiferet/clients/yaml.py,sha256=-Eo8PX2oPpVxv1c-cpkNOrGhxx9T7XPYoAyGi1DxMi4,2454
|
4
|
-
tiferet/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
tiferet/commands/container.py,sha256=L2IKJqEbRglw_LC144oYAkARr2Rixj8IFuC6Ro1jAqA,1789
|
6
|
-
tiferet/commands/error.py,sha256=ixMYH0yrEWlMAVGDSRke3IGoWaOShfmiXntrUC2b3wY,573
|
7
|
-
tiferet/commands/feature.py,sha256=tXa-MDf14ByIJqwQFeSUu2QLUjHPdsyvFNhj1XeaQVk,2507
|
8
|
-
tiferet/configs/__init__.py,sha256=NfT6XFNcJznOLXjMuNmj3XeaOPVWwbc-N4kVWaVjuD0,845
|
9
|
-
tiferet/configs/app.py,sha256=6N6EDInaKggFKR070a5j6Oex51CKXFaYh8gdrWOdeug,298
|
10
|
-
tiferet/contexts/__init__.py,sha256=6ElZETwHoWC-gUEm0XWnXbV_-liIgLGByGh62DO4AY8,140
|
11
|
-
tiferet/contexts/app.py,sha256=iZIrTrSJzTSZ6gg34jIlmE9u4a0GtsW6o-ksal24Pj8,3730
|
12
|
-
tiferet/contexts/container.py,sha256=FUZ-JPRj4Y6sEmcZMb_BBGjho93yTzu7Wr4c6gIXADk,5050
|
13
|
-
tiferet/contexts/env.py,sha256=GA6GfGOo1yKRzZBJijAfgAqRVBTM8uXPEPnCZMg33O4,3485
|
14
|
-
tiferet/contexts/error.py,sha256=VO3Wgkmf5bdK6LoT0xhQn1WeSAVulQwUhvBAsoUPd1c,2503
|
15
|
-
tiferet/contexts/feature.py,sha256=TB1ncuiBKYcMu2eIqbWtenCTjdvPcnHnyYYmmP4_DwI,2654
|
16
|
-
tiferet/contexts/request.py,sha256=TOECa0V1wKuNGCYFIRKxwsZVpLtP0FS_Nm96DaEVsWU,2726
|
17
|
-
tiferet/data/__init__.py,sha256=ts3bkFftArKTgUJj7q65Sob4fC6jOqfYNxm6cqjFr_w,74
|
18
|
-
tiferet/data/app.py,sha256=GUZz2io__p5wtNB-dwY2TkKBY9y_oJjTHzIZu6BLsoU,9651
|
19
|
-
tiferet/data/container.py,sha256=DMrw-jXTRgRAuxf8zmIftHwQkN9tBxBKj4pmcS7ZpB4,5182
|
20
|
-
tiferet/data/error.py,sha256=0JUxj1JPP9KWR1dWx5NU0WewWnZ8DSkb-X0V0XlxmWc,1852
|
21
|
-
tiferet/data/feature.py,sha256=s_aqVYhH7VKzXpWM3d-uvSv3_r8A0LgObv3Agg-CKoc,3697
|
22
|
-
tiferet/domain/__init__.py,sha256=uC1lHXzRnpoHqfgPcUraea5F_T1Nsx0wBau0paslsQg,146
|
23
|
-
tiferet/domain/app.py,sha256=Okkk8q6CrYjzN_c5GmsMWPuNGukjA25pL62HgwvDDkk,6201
|
24
|
-
tiferet/domain/container.py,sha256=Kw_xNn5_tWghcx3Dl_vPEdwZ2b8u23ZpbgMQ_bkUKaw,3666
|
25
|
-
tiferet/domain/core.py,sha256=iNL5w71FQjbNICSMTZnxFAqWl6b0Cj9V94vBM6NU03Y,4112
|
26
|
-
tiferet/domain/error.py,sha256=myUpdB4rgmbVBwIP8Pa88uastTSjPFGqrSwqR9C-VYg,3371
|
27
|
-
tiferet/domain/feature.py,sha256=RhedOKb8nG1D0J9b_aPVtJc_rQjLXwOpwpIsmzrH21o,4552
|
28
|
-
tiferet/repos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
|
-
tiferet/repos/app.py,sha256=0mPPScHy29YIoqYCkTffX3r9OgxvTlGikmfKNV1Yy4M,2767
|
30
|
-
tiferet/repos/container.py,sha256=2Medggn4BZrelnZ-cDZfFFwHaDB80R7iFJ5OF-6E62g,4811
|
31
|
-
tiferet/repos/error.py,sha256=8CEUd-FVfb4E6_w9gtQcaDv2V95CRZ2mWBRpTHttOcE,4249
|
32
|
-
tiferet/repos/feature.py,sha256=Z_S3nQU6wTe6YpXNsqp94EKrPa45w3uL9L93wRCLPHw,4745
|
33
|
-
tiferet/services/__init__.py,sha256=rwaCBwIfhqLkdXage-Q0hl_Ou7MAlGVW1Bg555uAUD8,44
|
34
|
-
tiferet/services/container.py,sha256=ISJhkiNLV--nHbAv6Ajd3ug1cGiyazZoePJOCJu5n_s,1130
|
35
|
-
tiferet-1.0.0a8.dist-info/LICENSE,sha256=e8_GutFM0sxbRlgUaeVsGvJ5uE-KvruLApOzIoHy_zU,1513
|
36
|
-
tiferet-1.0.0a8.dist-info/METADATA,sha256=GZz-LeMsA4ZrdKlJUQ7V_HRPzcQ9qWYqpgAMc0WtMbc,422
|
37
|
-
tiferet-1.0.0a8.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
38
|
-
tiferet-1.0.0a8.dist-info/top_level.txt,sha256=g19Qw0j_VxPw-fgPF1TMPwbtHjnEhNQs0fa69wJZ6IM,8
|
39
|
-
tiferet-1.0.0a8.dist-info/RECORD,,
|
File without changes
|
File without changes
|