tiferet 1.0.0a5__py3-none-any.whl → 1.0.0a6__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.
@@ -17,6 +17,14 @@ class ContainerContext(Model):
17
17
  A container context is a class that is used to create a container object.
18
18
  '''
19
19
 
20
+ # * attribute: interface_id
21
+ interface_id = StringType(
22
+ required=True,
23
+ metadata=dict(
24
+ description='The interface ID.'
25
+ ),
26
+ )
27
+
20
28
  # * attribute: attributes
21
29
  attributes = DictType(
22
30
  ModelType(ContainerAttribute),
@@ -65,37 +73,38 @@ class ContainerContext(Model):
65
73
  :param interface_flag: The interface flag.
66
74
  :type interface_flag: str
67
75
  :param feature_flag: The feature flag.
68
- :type feature_flag: str
76
+ :type feature_flag: str
69
77
  :param data_flag: The data flag.
70
78
  :type data_flag: str
71
79
  '''
72
80
 
73
- # Then set the interface id and injector flags.
74
- self.interface_id = interface_id
75
- self.feature_flag = feature_flag
76
- self.data_flag = data_flag
77
-
78
81
  # Add the attributes as an empty dictionary.
79
- self.attributes = {}
82
+ attributes = {}
80
83
 
81
84
  # Get and set attributes and constants.
82
85
  attrs, consts = container_repo.list_all()
83
86
 
84
87
  # Add the attributes to the context.
85
88
  for attr in attrs:
86
- attribute: ContainerAttribute = self.attributes[attr.id]
89
+ attribute: ContainerAttribute = attributes[attr.id]
87
90
 
88
91
  # If the attribute already exists, set the dependencies.
89
- if attr.id in self.attributes:
92
+ if attr.id in attributes:
90
93
  for dep in attr.dependencies:
91
94
  attribute.set_dependency(dep)
92
95
  continue
93
96
 
94
97
  # Otherwise, add the attribute.
95
- self.attributes[attr.id] = attr
96
-
97
- # Add the constants to the context.
98
- self.constants = consts
98
+ attributes[attr.id] = attr
99
+
100
+ # Add the constants and attributes to the context.
101
+ super().__init__(dict(
102
+ interface_id=interface_id,
103
+ feature_flag=feature_flag,
104
+ data_flag=data_flag,
105
+ attributes=attributes,
106
+ constants=consts,
107
+ ))
99
108
 
100
109
  # * method: get_dependency
101
110
  def get_dependency(self, attribute_id: str):
tiferet/contexts/env.py CHANGED
@@ -40,7 +40,13 @@ class EnvironmentContext(Model):
40
40
  app_repo = self.load_app_repo()
41
41
 
42
42
  # Load the interface configuration.
43
- self.interfaces = {interface.id: interface for interface in app_repo.list_interfaces()}
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)
44
50
 
45
51
  # * method: start
46
52
  def start(self, interface_id: str, **kwargs):
@@ -92,6 +98,7 @@ class EnvironmentContext(Model):
92
98
  # Get the default dependencies for the app interface.
93
99
  dependencies = dict(
94
100
  interface_id=app_interface.id,
101
+ app_name=app_interface.name,
95
102
  feature_flag=app_interface.feature_flag,
96
103
  data_flag=app_interface.data_flag,
97
104
  app_context=container_service.import_dependency(
@@ -106,7 +113,7 @@ class EnvironmentContext(Model):
106
113
 
107
114
  # Create the injector from the dependencies, constants, and the app interface.
108
115
  injector = container_service.create_injector(
109
- app_interface.id
116
+ app_interface.id,
110
117
  **dependencies
111
118
  )
112
119
 
@@ -31,13 +31,24 @@ class FeatureContext(Model):
31
31
  )
32
32
 
33
33
  # * method: init
34
- def __init__(self, feature_repo: FeatureRepository, container: ContainerContext):
34
+ def __init__(self, feature_repo: FeatureRepository, container_context: ContainerContext):
35
+ '''
36
+ Initialize the feature context.
37
+
38
+ :param feature_repo: The feature repository.
39
+ :type feature_repo: FeatureRepository
40
+ :param container_context: The container context.
41
+ :type container_context: ContainerContext
42
+ '''
35
43
 
36
- # Set the features.
37
- self.features = {feature.id: feature for feature in feature_repo.list()}
44
+ # Create the features.
45
+ features = {feature.id: feature for feature in feature_repo.list()}
38
46
 
39
- # Set the container context.
40
- self.container = container
47
+ # Set the features and container.
48
+ super().__init__(dict(
49
+ features=features,
50
+ container=container_context,
51
+ ))
41
52
 
42
53
  # * method: execute
43
54
  def execute(self, request: RequestContext, debug: bool = False, **kwargs):
tiferet/data/app.py CHANGED
@@ -143,7 +143,7 @@ class AppInterfaceYamlData(AppInterface, DataObject):
143
143
  default=AppDependencyYamlData.new(
144
144
  attribute_id='feature_repo',
145
145
  module_path='tiferet.repos.feature',
146
- class_name='FeatureRepository',
146
+ class_name='YamlProxy',
147
147
  ),
148
148
  metadata=dict(
149
149
  description='The feature repository dependency.'
@@ -157,7 +157,7 @@ class AppInterfaceYamlData(AppInterface, DataObject):
157
157
  default=AppDependencyYamlData.new(
158
158
  attribute_id='container_repo',
159
159
  module_path='tiferet.repos.container',
160
- class_name='ContainerRepository',
160
+ class_name='YamlProxy',
161
161
  ),
162
162
  metadata=dict(
163
163
  description='The container repository dependency.'
@@ -171,7 +171,7 @@ class AppInterfaceYamlData(AppInterface, DataObject):
171
171
  default=AppDependencyYamlData.new(
172
172
  attribute_id='error_repo',
173
173
  module_path='tiferet.repos.error',
174
- class_name='ErrorRepository',
174
+ class_name='YamlProxy',
175
175
  ),
176
176
  metadata=dict(
177
177
  description='The error repository dependency.'
tiferet/data/error.py CHANGED
@@ -76,24 +76,3 @@ class ErrorData(Error, DataObject):
76
76
  return ErrorData(
77
77
  super(ErrorData, ErrorData).new(**kwargs)
78
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
- )
tiferet/domain/app.py CHANGED
@@ -60,6 +60,7 @@ class AppInterface(Entity):
60
60
  # attribute: feature_flag
61
61
  feature_flag = StringType(
62
62
  required=True,
63
+ default='core',
63
64
  metadata=dict(
64
65
  description='The feature flag.'
65
66
  ),
@@ -114,6 +115,20 @@ class AppInterface(Entity):
114
115
  **kwargs
115
116
  )
116
117
 
118
+ # * method: get_dependency
119
+ def get_dependency(self, attribute_id: str) -> AppDependency:
120
+ '''
121
+ Get the dependency by attribute id.
122
+
123
+ :param attribute_id: The attribute id of the dependency.
124
+ :type attribute_id: str
125
+ :return: The dependency.
126
+ :rtype: AppDependency
127
+ '''
128
+
129
+ # Get the dependency by attribute id.
130
+ return next((dep for dep in self.dependencies if dep.attribute_id == attribute_id), None)
131
+
117
132
 
118
133
  # ** model: app_repository_configuration
119
134
  class AppRepositoryConfiguration(ModuleDependency):
@@ -164,7 +179,9 @@ class AppRepositoryConfiguration(ModuleDependency):
164
179
 
165
180
  # Create and return a new AppRepositoryConfiguration object.
166
181
  return AppRepositoryConfiguration(
167
- super(AppRepositoryConfiguration, AppRepositoryConfiguration).new(**kwargs),
182
+ super(AppRepositoryConfiguration, AppRepositoryConfiguration).new(
183
+ AppRepositoryConfiguration,
184
+ **kwargs),
168
185
  strict=False,
169
186
  )
170
187
 
tiferet/repos/error.py CHANGED
@@ -127,7 +127,7 @@ 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.from_yaml_data(
130
+ create_data=lambda data: ErrorData.new(
131
131
  id=id, **data),
132
132
  start_node=lambda data: data.get('errors').get(id))
133
133
 
@@ -146,8 +146,8 @@ 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: ErrorData.from_yaml_data(
150
- id=id, **data),
149
+ create_data=lambda data: {id: ErrorData.new(
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.
tiferet/repos/feature.py CHANGED
@@ -1,16 +1,22 @@
1
- from typing import Dict, Any, List
1
+ # *** imports
2
2
 
3
+ # ** core
4
+ from typing import List
5
+
6
+ # ** app
3
7
  from ..data.feature import FeatureData
4
8
  from ..domain.feature import Feature
9
+ from ..clients import yaml_client
5
10
 
6
- from ..clients import yaml as yaml_client
7
-
11
+ # *** repository
8
12
 
13
+ # ** interface: feature_repository
9
14
  class FeatureRepository(object):
10
15
  '''
11
16
  Feature repository interface.
12
17
  '''
13
18
 
19
+ # * method: exists
14
20
  def exists(self, id: str) -> bool:
15
21
  '''
16
22
  Verifies if the feature exists.
@@ -21,8 +27,10 @@ class FeatureRepository(object):
21
27
  :rtype: bool
22
28
  '''
23
29
 
30
+ # Not implemented.
24
31
  raise NotImplementedError()
25
32
 
33
+ # * method: get
26
34
  def get(self, id: str) -> Feature:
27
35
  '''
28
36
  Get the feature by id.
@@ -33,8 +41,10 @@ class FeatureRepository(object):
33
41
  :rtype: f.Feature
34
42
  '''
35
43
 
44
+ # Not implemented.
36
45
  raise NotImplementedError()
37
-
46
+
47
+ # * method: list
38
48
  def list(self, group_id: str = None) -> List[Feature]:
39
49
  '''
40
50
  List the features.
@@ -45,8 +55,10 @@ class FeatureRepository(object):
45
55
  :rtype: list
46
56
  '''
47
57
 
58
+ # Not implemented.
48
59
  raise NotImplementedError
49
60
 
61
+ # * method: save
50
62
  def save(self, feature: Feature):
51
63
  '''
52
64
  Save the feature.
@@ -55,25 +67,28 @@ class FeatureRepository(object):
55
67
  :type feature: f.Feature
56
68
  '''
57
69
 
70
+ # Not implemented.
58
71
  raise NotImplementedError()
59
72
 
60
-
73
+ # ** repository: yaml_proxy
61
74
  class YamlProxy(FeatureRepository):
62
75
  '''
63
76
  Yaml repository for features.
64
77
  '''
65
78
 
66
- def __init__(self, feature_yaml_base_path: str):
79
+ # * method: init
80
+ def __init__(self, feature_config_file: str):
67
81
  '''
68
82
  Initialize the yaml repository.
69
83
 
70
- :param feature_yaml_base_path: The base path to the yaml file.
71
- :type feature_yaml_base_path: str
84
+ :param feature_config_file: The feature configuration file.
85
+ :type feature_config_file: str
72
86
  '''
73
87
 
74
88
  # Set the base path.
75
- self.base_path = feature_yaml_base_path
89
+ self.config_file = feature_config_file
76
90
 
91
+ # * method: exists
77
92
  def exists(self, id: str) -> bool:
78
93
  '''
79
94
  Verifies if the feature exists.
@@ -90,6 +105,7 @@ class YamlProxy(FeatureRepository):
90
105
  # Return whether the feature exists.
91
106
  return feature is not None
92
107
 
108
+ # * method: get
93
109
  def get(self, id: str) -> Feature:
94
110
  '''
95
111
  Get the feature by id.
@@ -104,7 +120,7 @@ class YamlProxy(FeatureRepository):
104
120
 
105
121
  # Load feature data from yaml.
106
122
  _data: FeatureData = yaml_client.load(
107
- self.base_path,
123
+ self.config_file,
108
124
  create_data=lambda data: FeatureData.from_yaml_data(
109
125
  id=id,
110
126
  group_id=group_id,
@@ -120,6 +136,7 @@ class YamlProxy(FeatureRepository):
120
136
  # Return feature.
121
137
  return _data.map('to_object.yaml')
122
138
 
139
+ # * method: list
123
140
  def list(self, group_id: str = None) -> List[Feature]:
124
141
  '''
125
142
  List the features.
@@ -132,7 +149,7 @@ class YamlProxy(FeatureRepository):
132
149
 
133
150
  # Load all feature data from yaml.
134
151
  features = yaml_client.load(
135
- self.base_path,
152
+ self.config_file,
136
153
  create_data=lambda data: [FeatureData.from_yaml_data(
137
154
  id=id,
138
155
  **feature_data
@@ -147,6 +164,7 @@ class YamlProxy(FeatureRepository):
147
164
  # Return the list of features.
148
165
  return [feature.map('to_object.yaml') for feature in features]
149
166
 
167
+ # * method: save
150
168
  def save(self, feature: Feature):
151
169
  '''
152
170
  Save the feature.
@@ -160,7 +178,7 @@ class YamlProxy(FeatureRepository):
160
178
 
161
179
  # Update the feature data.
162
180
  yaml_client.save(
163
- self.base_path,
181
+ self.config_file,
164
182
  data=feature_data,
165
183
  data_save_path=f'features/{feature.group_id}.{feature_data.feature_key}'
166
184
  )
@@ -10,7 +10,7 @@ from dependencies import Injector
10
10
  # *** functions
11
11
 
12
12
  # ** function: import_dependency
13
- def import_dependency(module_path: str, class_name: str) -> Any:
13
+ def import_dependency(module_path: str, class_name: str, **kwargs) -> Any:
14
14
  '''
15
15
  Import an object dependency from its configured Python module.
16
16
 
@@ -18,6 +18,8 @@ def import_dependency(module_path: str, class_name: str) -> Any:
18
18
  :type module_path: str
19
19
  :param class_name: The class name.
20
20
  :type class_name: str
21
+ :param kwargs: Additional keyword arguments.
22
+ :type kwargs: dict
21
23
  :return: The dependency.
22
24
  :rtype: Any
23
25
  '''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tiferet
3
- Version: 1.0.0a5
3
+ Version: 1.0.0a6
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
@@ -9,18 +9,18 @@ tiferet/configs/__init__.py,sha256=NfT6XFNcJznOLXjMuNmj3XeaOPVWwbc-N4kVWaVjuD0,8
9
9
  tiferet/configs/app.py,sha256=XMBbwHS2y_Wm-scxVJ2mcAtBy0cRj5e0WLbi1F3R1Q4,299
10
10
  tiferet/contexts/__init__.py,sha256=6ElZETwHoWC-gUEm0XWnXbV_-liIgLGByGh62DO4AY8,140
11
11
  tiferet/contexts/app.py,sha256=MPRFu3ut7DOmc3i3PqLR96ymvWMShW6BUbY9eG8i6Eg,3296
12
- tiferet/contexts/container.py,sha256=zGCGm1lF0mI6AmEa9WK-N_Gwyv1oHSqUCOmLnkqvFyc,4871
13
- tiferet/contexts/env.py,sha256=Hhbv3sqmcVd61ck_5Uq8WWV171vaKIpIRTggeIdIrZ8,3253
12
+ tiferet/contexts/container.py,sha256=FUZ-JPRj4Y6sEmcZMb_BBGjho93yTzu7Wr4c6gIXADk,5050
13
+ tiferet/contexts/env.py,sha256=yTcymmwo4p-7A8Dg-VJGaYAN7D3Q9yMSQ41MAW9y8lA,3433
14
14
  tiferet/contexts/error.py,sha256=VO3Wgkmf5bdK6LoT0xhQn1WeSAVulQwUhvBAsoUPd1c,2503
15
- tiferet/contexts/feature.py,sha256=u7wEhdfTLeWKIv5i2nzBcu4cAcVkm6iqNNznczPmHjc,2293
15
+ tiferet/contexts/feature.py,sha256=TB1ncuiBKYcMu2eIqbWtenCTjdvPcnHnyYYmmP4_DwI,2654
16
16
  tiferet/contexts/request.py,sha256=TOECa0V1wKuNGCYFIRKxwsZVpLtP0FS_Nm96DaEVsWU,2726
17
17
  tiferet/data/__init__.py,sha256=ts3bkFftArKTgUJj7q65Sob4fC6jOqfYNxm6cqjFr_w,74
18
- tiferet/data/app.py,sha256=jZ-4fUTU-FPyaihMlmxVnSsRabcAX5ay56WbRsnKwds,9675
18
+ tiferet/data/app.py,sha256=GUZz2io__p5wtNB-dwY2TkKBY9y_oJjTHzIZu6BLsoU,9651
19
19
  tiferet/data/container.py,sha256=DMrw-jXTRgRAuxf8zmIftHwQkN9tBxBKj4pmcS7ZpB4,5182
20
- tiferet/data/error.py,sha256=lfGO3SjtsxSv6d7iKDeVw3vXfocCk29g4-uwC3jnaig,2377
20
+ tiferet/data/error.py,sha256=0JUxj1JPP9KWR1dWx5NU0WewWnZ8DSkb-X0V0XlxmWc,1852
21
21
  tiferet/data/feature.py,sha256=s_aqVYhH7VKzXpWM3d-uvSv3_r8A0LgObv3Agg-CKoc,3697
22
22
  tiferet/domain/__init__.py,sha256=uC1lHXzRnpoHqfgPcUraea5F_T1Nsx0wBau0paslsQg,146
23
- tiferet/domain/app.py,sha256=I3nFat5a73mlNvaBsTy_kIYVcv8F2mUN8MGbCxyxwtg,5640
23
+ tiferet/domain/app.py,sha256=Okkk8q6CrYjzN_c5GmsMWPuNGukjA25pL62HgwvDDkk,6201
24
24
  tiferet/domain/container.py,sha256=Kw_xNn5_tWghcx3Dl_vPEdwZ2b8u23ZpbgMQ_bkUKaw,3666
25
25
  tiferet/domain/core.py,sha256=iNL5w71FQjbNICSMTZnxFAqWl6b0Cj9V94vBM6NU03Y,4112
26
26
  tiferet/domain/error.py,sha256=myUpdB4rgmbVBwIP8Pa88uastTSjPFGqrSwqR9C-VYg,3371
@@ -28,12 +28,12 @@ tiferet/domain/feature.py,sha256=RhedOKb8nG1D0J9b_aPVtJc_rQjLXwOpwpIsmzrH21o,455
28
28
  tiferet/repos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  tiferet/repos/app.py,sha256=0mPPScHy29YIoqYCkTffX3r9OgxvTlGikmfKNV1Yy4M,2767
30
30
  tiferet/repos/container.py,sha256=2Medggn4BZrelnZ-cDZfFFwHaDB80R7iFJ5OF-6E62g,4811
31
- tiferet/repos/error.py,sha256=c3Bs2QTktMuJWGSRF8rKeTN5vFEsaOycUdYD7QSIDEc,4224
32
- tiferet/repos/feature.py,sha256=uR4s-n28J4WCO4Npi6AzOxk5R9I6HuUMHDzoK1Xo_80,4361
31
+ tiferet/repos/error.py,sha256=8CEUd-FVfb4E6_w9gtQcaDv2V95CRZ2mWBRpTHttOcE,4249
32
+ tiferet/repos/feature.py,sha256=Z_S3nQU6wTe6YpXNsqp94EKrPa45w3uL9L93wRCLPHw,4745
33
33
  tiferet/services/__init__.py,sha256=rwaCBwIfhqLkdXage-Q0hl_Ou7MAlGVW1Bg555uAUD8,44
34
- tiferet/services/container.py,sha256=yZU09pziCMz74UIRqiM_gHNqNE4Hml555WEuNoJlEDA,1048
35
- tiferet-1.0.0a5.dist-info/LICENSE,sha256=e8_GutFM0sxbRlgUaeVsGvJ5uE-KvruLApOzIoHy_zU,1513
36
- tiferet-1.0.0a5.dist-info/METADATA,sha256=R9SuKQafnfLIYmKLp8-ek9IC4jchvX0XpuOfXD8ZE1U,422
37
- tiferet-1.0.0a5.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
38
- tiferet-1.0.0a5.dist-info/top_level.txt,sha256=g19Qw0j_VxPw-fgPF1TMPwbtHjnEhNQs0fa69wJZ6IM,8
39
- tiferet-1.0.0a5.dist-info/RECORD,,
34
+ tiferet/services/container.py,sha256=ISJhkiNLV--nHbAv6Ajd3ug1cGiyazZoePJOCJu5n_s,1130
35
+ tiferet-1.0.0a6.dist-info/LICENSE,sha256=e8_GutFM0sxbRlgUaeVsGvJ5uE-KvruLApOzIoHy_zU,1513
36
+ tiferet-1.0.0a6.dist-info/METADATA,sha256=mIebZDZ0tw4e8dPum3ePSF_f7__cIwvnW8bdybZUnKo,422
37
+ tiferet-1.0.0a6.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
38
+ tiferet-1.0.0a6.dist-info/top_level.txt,sha256=g19Qw0j_VxPw-fgPF1TMPwbtHjnEhNQs0fa69wJZ6IM,8
39
+ tiferet-1.0.0a6.dist-info/RECORD,,