tiferet 1.0.0a12__py3-none-any.whl → 1.0.0a14__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.
@@ -1,7 +1,7 @@
1
1
  # *** imports
2
2
 
3
3
  # ** app
4
- from .app import AppInterfaceContext
4
+ from .app import AppContext, AppContext as App, AppInterfaceContext
5
5
  from .container import ContainerContext
6
6
  from .error import ErrorContext
7
7
  from .feature import FeatureContext
tiferet/contexts/app.py CHANGED
@@ -1,17 +1,123 @@
1
1
  # *** imports
2
2
 
3
3
  # ** core
4
- from typing import Any, Tuple
4
+ from typing import Dict, Any, Tuple
5
5
 
6
6
  # ** app
7
7
  from .request import RequestContext
8
8
  from .feature import FeatureContext
9
9
  from .error import ErrorContext
10
- from ..domain import *
10
+ from .container import create_injector, import_dependency
11
+ from ..domain import Model, StringType, DictType, ModelType
12
+ from ..domain import AppInterface
13
+ from ..repos import AppRepository
11
14
 
12
15
 
13
16
  # *** contexts
14
17
 
18
+ # ** context: app_context
19
+ class AppContext(Model):
20
+
21
+ # * attribute: app_repo_module_path
22
+ app_repo_module_path = StringType(
23
+ required=True,
24
+ default='tiferet.repos.app',
25
+ metadata=dict(
26
+ description='The application repository module path.'
27
+ ),
28
+ )
29
+
30
+ # * attribute: app_repo_class_name
31
+ app_repo_class_name = StringType(
32
+ required=True,
33
+ default='AppYamlProxy',
34
+ metadata=dict(
35
+ description='The application repository class name.'
36
+ ),
37
+ )
38
+
39
+ # * attribute: app_repo_parameters
40
+ app_repo_parameters = DictType(
41
+ StringType(),
42
+ default=dict(
43
+ app_config_file='app/configs/app.yaml'
44
+ ),
45
+ metadata=dict(
46
+ description='The application repository parameters.'
47
+ ),
48
+ )
49
+
50
+ # * method: run
51
+ def run(self, interface_id: str, **parameters):
52
+
53
+ # Import the app repository.
54
+ app_repo = self.import_app_repo(self.app_repo_module_path, self.app_repo_class_name)
55
+
56
+ # Get the app interface.
57
+ app_interface = app_repo.get_interface(interface_id)
58
+
59
+ # Create the injector.
60
+ injector = self.create_injector(app_interface)
61
+
62
+ # Load the app interface context.
63
+ app_interface_context: AppInterfaceContext = getattr(injector, 'app_context')
64
+
65
+ # Run the app interface context with the parameters.
66
+ return app_interface_context.run(**parameters)
67
+
68
+ # * method: import_app_repo
69
+ def import_app_repo(self, module_path: str, class_name: str, parameters: Dict[str, Any]) -> AppRepository:
70
+ '''
71
+ Import the app repository.
72
+
73
+ :param module_path: The module path.
74
+ :type module_path: str
75
+ :param class_name: The class name.
76
+ :type class_name: str
77
+ :param parameters: The parameters.
78
+ :type parameters: dict
79
+ :return: The app repository.
80
+ :rtype: AppRepository
81
+ '''
82
+
83
+ # Try to import the module provided.
84
+ try:
85
+ return import_dependency(module_path, class_name)(**parameters)
86
+
87
+ # Return None if nothing comes up.
88
+ except:
89
+ return None
90
+
91
+ # ** method: create_injector
92
+ def create_injector(self, app_interface: AppInterface) -> Any:
93
+ '''
94
+ Create the injector.
95
+
96
+ :param app_interface: The app interface.
97
+ :type app_interface: AppInterface
98
+ :return: The injector.
99
+ :rtype: Any
100
+ '''
101
+
102
+ # Get the dependencies for the app interface.
103
+ dependencies = dict(
104
+ interface_id=app_interface.id,
105
+ app_name=app_interface.name,
106
+ feature_flag=app_interface.feature_flag,
107
+ data_flag=app_interface.data_flag,
108
+ app_context=import_dependency(
109
+ **app_interface.get_dependency('app_context').to_primitive()
110
+ ),
111
+ **app_interface.constants
112
+ )
113
+
114
+ # Add the remaining dependencies from the app interface.
115
+ dependencies.update({dep.attribute_id: self.import_dependency(dep.module_path, dep.class_name) for dep in app_interface.dependencies})
116
+
117
+ # Create the injector.
118
+ return create_injector(app_interface.id, **dependencies)
119
+
120
+
15
121
  # ** context: app_interface_context
16
122
  class AppInterfaceContext(Model):
17
123
  '''
@@ -133,9 +239,10 @@ class AppInterfaceContext(Model):
133
239
  request, kwargs = self.parse_request(**kwargs)
134
240
 
135
241
  # Execute feature context and return session.
136
- # Handle error and return response if triggered.
137
242
  try:
138
243
  self.execute_feature(request, **kwargs)
244
+
245
+ # Handle error and return response if triggered.
139
246
  except Exception as e:
140
247
  print('Error:', e)
141
248
  return self.errors.handle_error(e)
@@ -6,10 +6,47 @@ from typing import Any
6
6
 
7
7
  # ** app
8
8
  from ..domain import *
9
- from ..services import container_service
10
9
  from ..repos.container import ContainerRepository
11
10
 
12
11
 
12
+ # *** functions
13
+
14
+ # ** function: create_injector
15
+ def create_injector(name: str, **dependencies) -> Any:
16
+ '''
17
+ Create an injector object with the given dependencies.
18
+
19
+ :param name: The name of the injector.
20
+ :type name: str
21
+ :param dependencies: The dependencies.
22
+ :type dependencies: dict
23
+ :return: The injector object.
24
+ :rtype: Any
25
+ '''
26
+
27
+ # Create container.
28
+ from dependencies import Injector
29
+ return type(f'{name.capitalize()}Container', (Injector,), {**dependencies})
30
+
31
+
32
+ # ** function: import_dependency
33
+ def import_dependency(module_path: str, class_name: str) -> Any:
34
+ '''
35
+ Import an object dependency from its configured Python module.
36
+
37
+ :param module_path: The module path.
38
+ :type module_path: str
39
+ :param class_name: The class name.
40
+ :type class_name: str
41
+ :return: The dependency.
42
+ :rtype: Any
43
+ '''
44
+
45
+ # Import module.
46
+ from importlib import import_module
47
+ return getattr(import_module(module_path), class_name)
48
+
49
+
13
50
  # *** contexts
14
51
 
15
52
  # ** contexts: container_context
@@ -165,7 +202,7 @@ class ContainerContext(Model):
165
202
  dependencies[attribute_id] = self.import_dependency(attribute, flag_map[attribute.type])
166
203
 
167
204
  # Create container.
168
- return container_service.create_injector(
205
+ return create_injector(
169
206
  self.interface_id,
170
207
  **self.constants,
171
208
  **dependencies,
@@ -192,4 +229,4 @@ class ContainerContext(Model):
192
229
  dependency = attribute.get_dependency('core')
193
230
 
194
231
  # Import the dependency.
195
- return container_service.import_dependency(dependency.module_path, dependency.class_name)
232
+ return import_dependency(dependency.module_path, dependency.class_name)
tiferet/contexts/error.py CHANGED
@@ -1,7 +1,7 @@
1
1
  # *** imports
2
2
 
3
3
  # ** core
4
- from typing import Any, Tuple
4
+ from typing import Any, Tuple, List
5
5
 
6
6
  # ** app
7
7
  from ..domain import *
@@ -37,10 +37,36 @@ class ErrorContext(Model):
37
37
  # Create the errors lookup from the error repository.
38
38
  errors = {error.name: error for error in error_repo.list()}
39
39
 
40
+ # Add custom errors.
41
+ errors.update({error.name: error for error in self.load_custom_errors()})
42
+
40
43
  # Set the errors lookup and validate.
41
44
  super().__init__(dict(errors=errors))
42
45
  self.validate()
43
46
 
47
+ # * method: load_custom_errors
48
+ def load_custom_errors(self) -> List[Error]:
49
+ '''
50
+ Load custom errors.
51
+
52
+ :return: The list of custom errors.
53
+ :rtype: list
54
+ '''
55
+
56
+ # Get custom errors.
57
+ return [
58
+ Error.new(
59
+ name='FEATURE_NOT_FOUND',
60
+ error_code='0',
61
+ message=[
62
+ ErrorMessage.new(
63
+ lang='en_US',
64
+ text='The feature with ID was not found: {}'
65
+ )
66
+ ]
67
+ )
68
+ ]
69
+
44
70
  # * method: handle_error
45
71
  def handle_error(self, exception: Exception, lang: str = 'en_US', **kwargs) -> Tuple[bool, Any]:
46
72
  '''
@@ -79,6 +79,9 @@ class FeatureContext(Model):
79
79
  :type kwargs: dict
80
80
  '''
81
81
 
82
+ # Assert the feature exists.
83
+ assert request.feature_id in self.features, 'FEATURE_NOT_FOUND, {}'.format(request.feature_id)
84
+
82
85
  # Iterate over the feature commands.
83
86
  for command in self.features[request.feature_id].commands:
84
87
 
tiferet/data/app.py CHANGED
@@ -6,7 +6,7 @@ from typing import Dict
6
6
  # ** app
7
7
  from ..configs import *
8
8
  from ..domain import DataObject
9
- from ..domain.app import AppDependency, AppInterface, AppRepositoryConfiguration
9
+ from ..domain.app import AppDependency, AppInterface
10
10
 
11
11
 
12
12
  # *** constants
@@ -283,54 +283,3 @@ class AppInterfaceYamlData(AppInterface, DataObject):
283
283
  **self.to_primitive('to_model'),
284
284
  **kwargs
285
285
  )
286
-
287
-
288
- # ** data: app_repository_configuration_yaml_data
289
- class AppRepositoryConfigurationYamlData(DataObject, AppRepositoryConfiguration):
290
- '''
291
- A YAML data representation of an app repository configuration object.
292
- '''
293
-
294
- class Options():
295
- '''
296
- The options for the app repository configuration data.
297
- '''
298
- serialize_when_none = False
299
- roles = {
300
- 'to_model': DataObject.allow(),
301
- 'to_data': DataObject.allow()
302
- }
303
-
304
- # * method: new
305
- @staticmethod
306
- def from_data(**kwargs) -> 'AppRepositoryConfigurationYamlData':
307
- '''
308
- Initializes a new YAML representation of an AppRepositoryConfiguration object.
309
-
310
- :param kwargs: Additional keyword arguments.
311
- :type kwargs: dict
312
- :return: A new AppRepositoryConfigurationData object.
313
- :rtype: AppRepositoryConfigurationData
314
- '''
315
-
316
- # Create a new AppRepositoryConfigurationData object.
317
- return super(AppRepositoryConfigurationYamlData, AppRepositoryConfigurationYamlData).from_data(
318
- AppRepositoryConfigurationYamlData,
319
- **kwargs
320
- )
321
-
322
- # * method: map
323
- def map(self, **kwargs) -> AppRepositoryConfiguration:
324
- '''
325
- Maps the app repository configuration data to an app repository configuration object.
326
-
327
- :param role: The role for the mapping.
328
- :type role: str
329
- :param kwargs: Additional keyword arguments.
330
- :type kwargs: dict
331
- :return: A new app repository configuration object.
332
- :rtype: AppRepositoryConfiguration
333
- '''
334
-
335
- # Map the app repository configuration data.
336
- return super().map(AppRepositoryConfiguration, **kwargs)
@@ -1,5 +1,5 @@
1
1
  from .core import *
2
- from .app import AppInterface, AppDependency, AppRepositoryConfiguration
2
+ from .app import AppInterface, AppDependency
3
3
  from .container import ContainerAttribute, ContainerDependency
4
- from .error import Error
4
+ from .error import Error, ErrorMessage
5
5
  from .feature import Feature
tiferet/domain/app.py CHANGED
@@ -128,59 +128,4 @@ class AppInterface(Entity):
128
128
 
129
129
  # Get the dependency by attribute id.
130
130
  return next((dep for dep in self.dependencies if dep.attribute_id == attribute_id), None)
131
-
132
-
133
- # ** model: app_repository_configuration
134
- class AppRepositoryConfiguration(ModuleDependency):
135
- '''
136
- The import configuration for the application repository.
137
- '''
138
-
139
- # * attribute: module_path
140
- module_path = StringType(
141
- required=True,
142
- default='tiferet.repos.app',
143
- metadata=dict(
144
- description='The module path for the application repository.'
145
- ),
146
- )
147
-
148
- # * attribute: class_name
149
- class_name = StringType(
150
- required=True,
151
- default='YamlProxy',
152
- metadata=dict(
153
- description='The class name for the application repository.'
154
- ),
155
- )
156
-
157
- # * attribute: params
158
- params = DictType(
159
- StringType,
160
- default=dict(
161
- app_config_file='app/configs/app.yml',
162
- ),
163
- metadata=dict(
164
- description='The application repository configuration parameters.'
165
- ),
166
- )
167
-
168
- # * method: new
169
- @staticmethod
170
- def new(**kwargs) -> 'AppRepositoryConfiguration':
171
- '''
172
- Initializes a new AppRepositoryConfiguration object.
173
-
174
- :param kwargs: Additional keyword arguments.
175
- :type kwargs: dict
176
- :return: A new AppRepositoryConfiguration object.
177
- :rtype: AppRepositoryConfiguration
178
- '''
179
-
180
- # Create and return a new AppRepositoryConfiguration object.
181
- return AppRepositoryConfiguration(
182
- super(AppRepositoryConfiguration, AppRepositoryConfiguration).new(
183
- AppRepositoryConfiguration,
184
- **kwargs),
185
- strict=False,
186
- )
131
+
tiferet/repos/app.py CHANGED
@@ -41,8 +41,8 @@ class AppRepository(object):
41
41
  raise NotImplementedError()
42
42
 
43
43
 
44
- # ** proxy: yaml_proxy
45
- class YamlProxy(object):
44
+ # ** proxy: app_yaml_proxy
45
+ class AppYamlProxy(AppRepository):
46
46
 
47
47
  # * field: config_file
48
48
  config_file: str = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tiferet
3
- Version: 1.0.0a12
3
+ Version: 1.0.0a14
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
@@ -6,33 +6,30 @@ tiferet/commands/container.py,sha256=L2IKJqEbRglw_LC144oYAkARr2Rixj8IFuC6Ro1jAqA
6
6
  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
- tiferet/contexts/__init__.py,sha256=HjI-9n29mFxN6ILSa3LBhLSVPRe-1V36ffQXSP9RavM,204
10
- tiferet/contexts/app.py,sha256=uCSUWZlhieyI97tFgJ0VzHqhBxrPo_if0CLCPEPBSaM,3783
11
- tiferet/contexts/container.py,sha256=qQzrAxGoq5yNqijMnVzE2wVwKprBmEVgiaBunnNcMd8,5704
12
- tiferet/contexts/error.py,sha256=mS72JU7rlxs9yEeDj5ZW3DuJftYqmkyp8DOhzNUwtMw,2562
13
- tiferet/contexts/feature.py,sha256=CnfgvYvApjkOa2fpZw9Vz6a7fsmiVx7mXaeZT2g9HGc,3589
9
+ tiferet/contexts/__init__.py,sha256=PvTgdVMav7B4pbKV4vxfNTMSod88DKGSR_0W8reIyC4,235
10
+ tiferet/contexts/app.py,sha256=3vMjr5WwMBZPY6KjHZ6MPMke-5C1Waxr5fcgl-g04SA,7192
11
+ tiferet/contexts/container.py,sha256=Wo_2HENb7XPpIcZSkEikSGh8vWmClpLgkBbSW-jMDK4,6619
12
+ tiferet/contexts/error.py,sha256=Gqewmk5WqbER9umNvR9gliQNi-bmbaNyXOSG4jUZfJc,3262
13
+ tiferet/contexts/feature.py,sha256=kVVRpIyjWa3T2QoT2R-T7clOIQEpNMYa8ZJRVxgY_6o,3730
14
14
  tiferet/contexts/request.py,sha256=EwTyXVYi8z1t1ns_0yDrjY6qICIMPn1UvZpV7ULKReY,2756
15
15
  tiferet/data/__init__.py,sha256=JKaeCw508WY15-etqdFJxPUUJxMxCAi6ASmA472D1_s,93
16
- tiferet/data/app.py,sha256=TWWwP0MDpQ-LSKg9166CyPSeI7jjcklIfwBlLW_rT5c,9619
16
+ tiferet/data/app.py,sha256=dQXcC-A9oDJrwJCqkLSO9KyyldxtUjF7hGmfJqMzEXs,7881
17
17
  tiferet/data/container.py,sha256=o2HnLN1LasqWGP_S1Ub32CrCqYzehlD3dgXizW9XfU8,6154
18
18
  tiferet/data/error.py,sha256=Kllt0w62BAyShdVSwATN0LiVTeQHqkyQAN9_HuFg31Q,2339
19
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
20
+ tiferet/domain/__init__.py,sha256=vlZizSMkzaDYAZVHDB_YPaS3mo57vyW53DWaaSZhhkw,196
21
+ tiferet/domain/app.py,sha256=CYFK8KqkBqpAWNY45jMN-r_Tf7sell2R6pqquo7cmJg,3242
22
22
  tiferet/domain/container.py,sha256=wjal73hWAs5EvRO9XbrBBfdpV9nq9J89mAPbd4SH4ws,3666
23
23
  tiferet/domain/core.py,sha256=fOZeGxTJLGzY2zgAoSJu6rVJySpv-vCycT-WcEMk8kI,5152
24
24
  tiferet/domain/error.py,sha256=tWoJqg81LtfZfArN5OJRPVaZrAFcET0YUJJs52KHqYA,3853
25
25
  tiferet/domain/feature.py,sha256=drkCfhuIQhT05m61QzKdscaFdP0f-4K4tqO98lzXOjM,4866
26
26
  tiferet/repos/__init__.py,sha256=m6YLp90oqqs0cXQKOrDxudcc8P-AbeJ87a8okgoU7uI,171
27
- tiferet/repos/app.py,sha256=S7HM_iH_UkittmTZTO6Dxff9IYjXlE-QjG31X3bPnaA,2886
27
+ 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/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.0a12.dist-info/LICENSE,sha256=e8_GutFM0sxbRlgUaeVsGvJ5uE-KvruLApOzIoHy_zU,1513
35
- tiferet-1.0.0a12.dist-info/METADATA,sha256=8EJHzXJ4_yjBoxcaIUuEEryDaBcQum6KshthF3z7EJ8,536
36
- tiferet-1.0.0a12.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
37
- tiferet-1.0.0a12.dist-info/top_level.txt,sha256=g19Qw0j_VxPw-fgPF1TMPwbtHjnEhNQs0fa69wJZ6IM,8
38
- tiferet-1.0.0a12.dist-info/RECORD,,
31
+ tiferet-1.0.0a14.dist-info/LICENSE,sha256=e8_GutFM0sxbRlgUaeVsGvJ5uE-KvruLApOzIoHy_zU,1513
32
+ tiferet-1.0.0a14.dist-info/METADATA,sha256=p17Z9Eywv7FLOn8XpujluWSMYXvEGuCwaxtwWoBNO4M,536
33
+ tiferet-1.0.0a14.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
34
+ tiferet-1.0.0a14.dist-info/top_level.txt,sha256=g19Qw0j_VxPw-fgPF1TMPwbtHjnEhNQs0fa69wJZ6IM,8
35
+ tiferet-1.0.0a14.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- # *** imports
2
-
3
- # ** app
4
- from . import container as container_service
5
- from . import app as app_service
tiferet/services/app.py DELETED
@@ -1,52 +0,0 @@
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,46 +0,0 @@
1
- # *** imports
2
-
3
- # ** core
4
- from typing import Any
5
-
6
- # ** infra
7
- from dependencies import Injector
8
-
9
-
10
- # *** functions
11
-
12
- # ** function: import_dependency
13
- def import_dependency(module_path: str, class_name: str, **kwargs) -> Any:
14
- '''
15
- Import an object dependency from its configured Python module.
16
-
17
- :param module_path: The module path.
18
- :type module_path: str
19
- :param class_name: The class name.
20
- :type class_name: str
21
- :param kwargs: Additional keyword arguments.
22
- :type kwargs: dict
23
- :return: The dependency.
24
- :rtype: Any
25
- '''
26
-
27
- # Import module.
28
- from importlib import import_module
29
- return getattr(import_module(module_path), class_name)
30
-
31
-
32
- # ** function: create_injector
33
- def create_injector(name: str, **dependencies) -> Any:
34
- '''
35
- Create an injector object with the given dependencies.
36
-
37
- :param name: The name of the injector.
38
- :type name: str
39
- :param dependencies: The dependencies.
40
- :type dependencies: dict
41
- :return: The injector object.
42
- :rtype: Any
43
- '''
44
-
45
- # Create container.
46
- return type(f'{name.capitalize()}Container', (Injector,), {**dependencies})