tiferet 1.0.0a14__py3-none-any.whl → 1.0.0a16__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/contexts/app.py +54 -16
- {tiferet-1.0.0a14.dist-info → tiferet-1.0.0a16.dist-info}/METADATA +1 -1
- {tiferet-1.0.0a14.dist-info → tiferet-1.0.0a16.dist-info}/RECORD +6 -6
- {tiferet-1.0.0a14.dist-info → tiferet-1.0.0a16.dist-info}/LICENSE +0 -0
- {tiferet-1.0.0a14.dist-info → tiferet-1.0.0a16.dist-info}/WHEEL +0 -0
- {tiferet-1.0.0a14.dist-info → tiferet-1.0.0a16.dist-info}/top_level.txt +0 -0
tiferet/contexts/app.py
CHANGED
@@ -40,7 +40,7 @@ class AppContext(Model):
|
|
40
40
|
app_repo_parameters = DictType(
|
41
41
|
StringType(),
|
42
42
|
default=dict(
|
43
|
-
app_config_file='app/configs/app.
|
43
|
+
app_config_file='app/configs/app.yml'
|
44
44
|
),
|
45
45
|
metadata=dict(
|
46
46
|
description='The application repository parameters.'
|
@@ -48,25 +48,57 @@ class AppContext(Model):
|
|
48
48
|
)
|
49
49
|
|
50
50
|
# * method: run
|
51
|
-
def run(self, interface_id: str, **
|
51
|
+
def run(self, interface_id: str, dependencies: Dict[str, Any] = {}, **kwargs) -> Any:
|
52
|
+
'''
|
53
|
+
Run the application interface.
|
54
|
+
|
55
|
+
:param interface_id: The interface ID.
|
56
|
+
:type interface_id: str
|
57
|
+
:param dependencies: The dependencies.
|
58
|
+
:type dependencies: dict
|
59
|
+
:param kwargs: Additional keyword arguments.
|
60
|
+
:type kwargs: dict
|
61
|
+
:return: The response.
|
62
|
+
:rtype: Any
|
63
|
+
'''
|
64
|
+
|
65
|
+
# Load the interface.
|
66
|
+
app_interface = self.load_interface(interface_id, **dependencies)
|
67
|
+
|
68
|
+
# Run the interface.
|
69
|
+
return app_interface.run(**kwargs)
|
70
|
+
|
71
|
+
# * method: load_interface
|
72
|
+
def load_interface(self, interface_id: str, **dependencies) -> AppInterface:
|
73
|
+
'''
|
74
|
+
Load the application interface.
|
75
|
+
|
76
|
+
:param interface_id: The interface ID.
|
77
|
+
:type interface_id: str
|
78
|
+
:param dependencies: The dependencies.
|
79
|
+
:type dependencies: dict
|
80
|
+
:return: The application interface.
|
81
|
+
:rtype: AppInterface
|
82
|
+
'''
|
52
83
|
|
53
84
|
# Import the app repository.
|
54
|
-
app_repo = self.import_app_repo(
|
85
|
+
app_repo = self.import_app_repo(
|
86
|
+
self.app_repo_module_path,
|
87
|
+
self.app_repo_class_name,
|
88
|
+
**self.app_repo_parameters
|
89
|
+
)
|
55
90
|
|
56
91
|
# Get the app interface.
|
57
92
|
app_interface = app_repo.get_interface(interface_id)
|
58
93
|
|
59
94
|
# Create the injector.
|
60
|
-
injector = self.create_injector(app_interface)
|
95
|
+
injector = self.create_injector(app_interface, **dependencies)
|
61
96
|
|
62
97
|
# Load the app interface context.
|
63
|
-
|
64
|
-
|
65
|
-
# Run the app interface context with the parameters.
|
66
|
-
return app_interface_context.run(**parameters)
|
98
|
+
return getattr(injector, 'app_context')
|
67
99
|
|
68
100
|
# * method: import_app_repo
|
69
|
-
def import_app_repo(self, module_path: str, class_name: str,
|
101
|
+
def import_app_repo(self, module_path: str, class_name: str, **kwargs) -> AppRepository:
|
70
102
|
'''
|
71
103
|
Import the app repository.
|
72
104
|
|
@@ -74,31 +106,36 @@ class AppContext(Model):
|
|
74
106
|
:type module_path: str
|
75
107
|
:param class_name: The class name.
|
76
108
|
:type class_name: str
|
77
|
-
:param
|
78
|
-
:type
|
109
|
+
:param kwargs: Additional keyword arguments.
|
110
|
+
:type kwargs: dict
|
79
111
|
:return: The app repository.
|
80
112
|
:rtype: AppRepository
|
81
113
|
'''
|
82
114
|
|
83
115
|
# Try to import the module provided.
|
84
116
|
try:
|
85
|
-
return import_dependency(module_path, class_name)(**
|
117
|
+
return import_dependency(module_path, class_name)(**kwargs)
|
86
118
|
|
87
119
|
# Return None if nothing comes up.
|
88
120
|
except:
|
89
121
|
return None
|
90
122
|
|
91
123
|
# ** method: create_injector
|
92
|
-
def create_injector(self, app_interface: AppInterface) -> Any:
|
124
|
+
def create_injector(self, app_interface: AppInterface, **kwargs) -> Any:
|
93
125
|
'''
|
94
126
|
Create the injector.
|
95
127
|
|
96
128
|
:param app_interface: The app interface.
|
97
129
|
:type app_interface: AppInterface
|
130
|
+
:param kwargs: Additional keyword arguments.
|
131
|
+
:type kwargs: dict
|
98
132
|
:return: The injector.
|
99
133
|
:rtype: Any
|
100
134
|
'''
|
101
135
|
|
136
|
+
# Retrieve the app context dependency.
|
137
|
+
app_context = app_interface.get_dependency('app_context')
|
138
|
+
|
102
139
|
# Get the dependencies for the app interface.
|
103
140
|
dependencies = dict(
|
104
141
|
interface_id=app_interface.id,
|
@@ -106,16 +143,17 @@ class AppContext(Model):
|
|
106
143
|
feature_flag=app_interface.feature_flag,
|
107
144
|
data_flag=app_interface.data_flag,
|
108
145
|
app_context=import_dependency(
|
109
|
-
|
146
|
+
app_context.module_path,
|
147
|
+
app_context.class_name,
|
110
148
|
),
|
111
149
|
**app_interface.constants
|
112
150
|
)
|
113
151
|
|
114
152
|
# Add the remaining dependencies from the app interface.
|
115
|
-
dependencies.update({dep.attribute_id:
|
153
|
+
dependencies.update({dep.attribute_id: import_dependency(dep.module_path, dep.class_name) for dep in app_interface.dependencies})
|
116
154
|
|
117
155
|
# Create the injector.
|
118
|
-
return create_injector(app_interface.id, **dependencies)
|
156
|
+
return create_injector(app_interface.id, **dependencies, **kwargs)
|
119
157
|
|
120
158
|
|
121
159
|
# ** context: app_interface_context
|
@@ -7,7 +7,7 @@ tiferet/commands/error.py,sha256=ixMYH0yrEWlMAVGDSRke3IGoWaOShfmiXntrUC2b3wY,573
|
|
7
7
|
tiferet/commands/feature.py,sha256=tXa-MDf14ByIJqwQFeSUu2QLUjHPdsyvFNhj1XeaQVk,2507
|
8
8
|
tiferet/configs/__init__.py,sha256=NfT6XFNcJznOLXjMuNmj3XeaOPVWwbc-N4kVWaVjuD0,845
|
9
9
|
tiferet/contexts/__init__.py,sha256=PvTgdVMav7B4pbKV4vxfNTMSod88DKGSR_0W8reIyC4,235
|
10
|
-
tiferet/contexts/app.py,sha256=
|
10
|
+
tiferet/contexts/app.py,sha256=_GiawlFowEbnVvBw6XgUlLjgLu2CwlHuK4ldT_v6a1c,8305
|
11
11
|
tiferet/contexts/container.py,sha256=Wo_2HENb7XPpIcZSkEikSGh8vWmClpLgkBbSW-jMDK4,6619
|
12
12
|
tiferet/contexts/error.py,sha256=Gqewmk5WqbER9umNvR9gliQNi-bmbaNyXOSG4jUZfJc,3262
|
13
13
|
tiferet/contexts/feature.py,sha256=kVVRpIyjWa3T2QoT2R-T7clOIQEpNMYa8ZJRVxgY_6o,3730
|
@@ -28,8 +28,8 @@ tiferet/repos/app.py,sha256=VxPanqWw4lGi1VoajTXN3sv9yy_XV6m_95E6DTdMHb8,2900
|
|
28
28
|
tiferet/repos/container.py,sha256=n9Tz83QETdAocGAT4oKcvllEGwFp069pYqkXs2-KFFk,3519
|
29
29
|
tiferet/repos/error.py,sha256=jDze41uioKwKEkAswkzLubVw-bxsVyeUkJwyeO5Es0E,4245
|
30
30
|
tiferet/repos/feature.py,sha256=GxOV8XHNwz9YY3I8Wch6GaDskvkdi8l1hM9E9fCg1y0,3644
|
31
|
-
tiferet-1.0.
|
32
|
-
tiferet-1.0.
|
33
|
-
tiferet-1.0.
|
34
|
-
tiferet-1.0.
|
35
|
-
tiferet-1.0.
|
31
|
+
tiferet-1.0.0a16.dist-info/LICENSE,sha256=e8_GutFM0sxbRlgUaeVsGvJ5uE-KvruLApOzIoHy_zU,1513
|
32
|
+
tiferet-1.0.0a16.dist-info/METADATA,sha256=dKLPaHr_RbeicLXsSYVKI6bsPY-ZmCyOqgTyXDdA9oo,536
|
33
|
+
tiferet-1.0.0a16.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
34
|
+
tiferet-1.0.0a16.dist-info/top_level.txt,sha256=g19Qw0j_VxPw-fgPF1TMPwbtHjnEhNQs0fa69wJZ6IM,8
|
35
|
+
tiferet-1.0.0a16.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|