tiferet 1.0.0a19__py3-none-any.whl → 1.0.0b0__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.
Files changed (59) hide show
  1. tiferet/__init__.py +3 -2
  2. tiferet/commands/__init__.py +6 -0
  3. tiferet/commands/app.py +102 -0
  4. tiferet/commands/core.py +124 -0
  5. tiferet/commands/dependencies.py +76 -0
  6. tiferet/commands/settings.py +101 -0
  7. tiferet/configs/__init__.py +3 -67
  8. tiferet/configs/error.py +48 -0
  9. tiferet/configs/settings.py +37 -0
  10. tiferet/contexts/__init__.py +0 -8
  11. tiferet/contexts/app.py +215 -182
  12. tiferet/contexts/cache.py +76 -0
  13. tiferet/contexts/container.py +92 -190
  14. tiferet/contexts/error.py +78 -80
  15. tiferet/contexts/feature.py +120 -83
  16. tiferet/contracts/__init__.py +4 -0
  17. tiferet/contracts/app.py +92 -0
  18. tiferet/contracts/cache.py +70 -0
  19. tiferet/contracts/container.py +147 -0
  20. tiferet/contracts/error.py +177 -0
  21. tiferet/contracts/feature.py +159 -0
  22. tiferet/contracts/settings.py +34 -0
  23. tiferet/data/__init__.py +3 -4
  24. tiferet/data/app.py +71 -208
  25. tiferet/data/container.py +52 -38
  26. tiferet/data/error.py +15 -24
  27. tiferet/data/feature.py +27 -8
  28. tiferet/{domain/core.py → data/settings.py} +36 -96
  29. tiferet/handlers/__init__.py +0 -0
  30. tiferet/handlers/container.py +116 -0
  31. tiferet/handlers/error.py +49 -0
  32. tiferet/handlers/feature.py +94 -0
  33. tiferet/models/__init__.py +4 -0
  34. tiferet/models/app.py +150 -0
  35. tiferet/models/container.py +135 -0
  36. tiferet/{domain → models}/error.py +86 -36
  37. tiferet/{domain → models}/feature.py +107 -47
  38. tiferet/models/settings.py +148 -0
  39. tiferet/proxies/__init__.py +0 -0
  40. tiferet/proxies/yaml/__init__.py +0 -0
  41. tiferet/{repos → proxies/yaml}/app.py +13 -41
  42. tiferet/{repos → proxies/yaml}/container.py +26 -56
  43. tiferet/{repos → proxies/yaml}/error.py +11 -70
  44. tiferet/proxies/yaml/feature.py +92 -0
  45. {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info}/METADATA +12 -3
  46. tiferet-1.0.0b0.dist-info/RECORD +51 -0
  47. {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info}/WHEEL +1 -1
  48. tiferet/commands/container.py +0 -54
  49. tiferet/commands/error.py +0 -21
  50. tiferet/commands/feature.py +0 -90
  51. tiferet/contexts/request.py +0 -110
  52. tiferet/domain/__init__.py +0 -5
  53. tiferet/domain/app.py +0 -131
  54. tiferet/domain/container.py +0 -141
  55. tiferet/repos/__init__.py +0 -7
  56. tiferet/repos/feature.py +0 -151
  57. tiferet-1.0.0a19.dist-info/RECORD +0 -35
  58. {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info/licenses}/LICENSE +0 -0
  59. {tiferet-1.0.0a19.dist-info → tiferet-1.0.0b0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,177 @@
1
+ # *** imports
2
+
3
+ # ** core
4
+ from typing import List, Dict, Any
5
+ from abc import abstractmethod
6
+
7
+ # ** app
8
+ from .settings import *
9
+
10
+
11
+ # *** contracts
12
+
13
+ # ** contract: error_message
14
+ class ErrorMessage(ModelContract):
15
+ '''
16
+ Contract for an error message translation.
17
+ '''
18
+
19
+ # * attribute: lang
20
+ lang: str
21
+
22
+ # * attribute: text
23
+ text: str
24
+
25
+ # * method: format
26
+ @abstractmethod
27
+ def format(self, *args) -> str:
28
+ '''
29
+ Format the error message text with provided arguments.
30
+
31
+ :param args: The arguments to format the error message text.
32
+ :type args: tuple
33
+ :return: The formatted error message text.
34
+ :rtype: str
35
+ '''
36
+ raise NotImplementedError('The format method must be implemented by the error message.')
37
+
38
+
39
+ # ** contract: error
40
+ class Error(ModelContract):
41
+ '''
42
+ Contract for an error object with multilingual messages.
43
+ '''
44
+
45
+ # * attribute: id
46
+ id: str
47
+
48
+ # * attribute: name
49
+ name: str
50
+
51
+ # * attribute: error_code
52
+ error_code: str
53
+
54
+ # * attribute: message
55
+ message: List[ErrorMessage]
56
+
57
+ # * method: format_message
58
+ @abstractmethod
59
+ def format_message(self, lang: str = 'en_US', *args) -> str:
60
+ '''
61
+ Format the error message for a specified language.
62
+
63
+ :param lang: The language of the error message text (default: en_US).
64
+ :type lang: str
65
+ :param args: The format arguments for the error message text.
66
+ :type args: tuple
67
+ :return: The formatted error message text.
68
+ :rtype: str
69
+ '''
70
+ raise NotImplementedError('The format_message method must be implemented by the error.')
71
+
72
+ # * method: format_response
73
+ @abstractmethod
74
+ def format_response(self, lang: str = 'en_US', *args, **kwargs) -> Dict[str, Any]:
75
+ '''
76
+ Generate a formatted error response for a specified language.
77
+
78
+ :param lang: The language of the error message text (default: en_US).
79
+ :type lang: str
80
+ :param args: The format arguments for the error message text.
81
+ :type args: tuple
82
+ :param kwargs: Additional keyword arguments for the response.
83
+ :type kwargs: dict
84
+ :return: The formatted error response.
85
+ :rtype: Dict[str, Any]
86
+ '''
87
+ raise NotImplementedError('The format_response method must be implemented by the error.')
88
+
89
+ # * method: set_message
90
+ @abstractmethod
91
+ def set_message(self, lang: str, text: str) -> None:
92
+ '''
93
+ Set or update the error message text for a specified language.
94
+
95
+ :param lang: The language of the error message text.
96
+ :type lang: str
97
+ :param text: The error message text.
98
+ :type text: str
99
+ '''
100
+ raise NotImplementedError('The set_message method must be implemented by the error.')
101
+
102
+
103
+ # ** contract: error_repository
104
+ class ErrorRepository(Repository):
105
+ '''
106
+ Contract for an error repository to manage error objects.
107
+ '''
108
+
109
+ # * method: exists
110
+ @abstractmethod
111
+ def exists(self, id: str, **kwargs) -> bool:
112
+ '''
113
+ Check if the error exists.
114
+
115
+ :param id: The error id.
116
+ :type id: str
117
+ :param kwargs: Additional keyword arguments.
118
+ :type kwargs: dict
119
+ :return: Whether the error exists.
120
+ :rtype: bool
121
+ '''
122
+ raise NotImplementedError('The exists method must be implemented by the error repository.')
123
+
124
+ # * method: get
125
+ @abstractmethod
126
+ def get(self, id: str) -> Error:
127
+ '''
128
+ Get an error object by its ID.
129
+
130
+ :param id: The error id.
131
+ :type id: str
132
+ :return: The error object.
133
+ :rtype: Error
134
+ '''
135
+ raise NotImplementedError('The get method must be implemented by the error repository.')
136
+
137
+ # * method: list
138
+ @abstractmethod
139
+ def list(self) -> List[Error]:
140
+ '''
141
+ List all error objects.
142
+
143
+ :return: The list of error objects.
144
+ :rtype: List[Error]
145
+ '''
146
+ raise NotImplementedError('The list method must be implemented by the error repository.')
147
+
148
+ # * method: save
149
+ @abstractmethod
150
+ def save(self, error: Error) -> None:
151
+ '''
152
+ Save the error.
153
+
154
+ :param error: The error.
155
+ :type error: Error
156
+ '''
157
+ raise NotImplementedError('The save method must be implemented by the error repository.')
158
+
159
+
160
+ # ** contract: error_service
161
+ class ErrorService(Service):
162
+ '''
163
+ Contract for an error service to handle error operations.
164
+ '''
165
+
166
+ # * method: load_errors
167
+ @abstractmethod
168
+ def load_errors(self, configured_errors: List[Error] = []) -> List[Error]:
169
+ '''
170
+ Load errors by their codes.
171
+
172
+ :param configured_errors: The list of hard-coded errors to load.
173
+ :type configured_errors: List[Error]
174
+ :return: The list of loaded errors.
175
+ :rtype: List[Error]
176
+ '''
177
+ raise NotImplementedError('The load_errors method must be implemented by the error service.')
@@ -0,0 +1,159 @@
1
+ # *** imports
2
+
3
+ # ** core
4
+ from typing import List, Dict, Any
5
+ from abc import abstractmethod
6
+
7
+ # ** app
8
+ from .settings import *
9
+
10
+
11
+ # *** contacts
12
+
13
+ # ** contract: request
14
+ class Request(ModelContract):
15
+ '''
16
+ Request contract for feature execution.
17
+ '''
18
+
19
+ # * attribute: headers
20
+ headers: Dict[str, str]
21
+
22
+ # * attribute: data
23
+ data: Dict[str, Any]
24
+
25
+ # * attribute: debug
26
+ debug: bool
27
+
28
+ # * attribute: result
29
+ result: str
30
+
31
+ # * method: set_result
32
+ def set_result(self, result: Any):
33
+ '''
34
+ Set the result of the request.
35
+
36
+ :param result: The result to set.
37
+ :type result: Any
38
+ '''
39
+ raise NotImplementedError('The set_result method must be implemented by the request model.')
40
+
41
+
42
+ # ** contract: feature_command
43
+ class FeatureCommand(ModelContract):
44
+ '''
45
+ Feature command contract.
46
+ '''
47
+
48
+ # * attribute: id
49
+ id: str
50
+
51
+ # * attribute: name
52
+ name: str
53
+
54
+ # * attribute: description
55
+ description: str
56
+
57
+ # * attribute: data_key
58
+ data_key: str
59
+
60
+ # * attribute: pass_on_error
61
+ pass_on_error: bool
62
+
63
+ # * attribute: parameters
64
+ parameters: Dict[str, Any]
65
+
66
+
67
+ # ** contract: feature
68
+ class Feature(ModelContract):
69
+ '''
70
+ Feature contract.
71
+ '''
72
+
73
+ # * attribute: id
74
+ id: str
75
+
76
+ # * attribute: commands
77
+ commands: List[FeatureCommand]
78
+
79
+
80
+ # ** contract: feature_repository
81
+ class FeatureRepository(Repository):
82
+ '''
83
+ Feature repository interface.
84
+ '''
85
+
86
+ # * method: exists
87
+ @abstractmethod
88
+ def exists(self, id: str) -> bool:
89
+ '''
90
+ Verifies if the feature exists.
91
+
92
+ :param id: The feature id.
93
+ :type id: str
94
+ :return: Whether the feature exists.
95
+ :rtype: bool
96
+ '''
97
+ raise NotImplementedError('The exists method must be implemented by the feature repository.')
98
+
99
+ # * method: get
100
+ @abstractmethod
101
+ def get(self, id: str) -> Feature:
102
+ '''
103
+ Get the feature by id.
104
+
105
+ :param id: The feature id.
106
+ :type id: str
107
+ :return: The feature object.
108
+ :rtype: Any
109
+ '''
110
+ raise NotImplementedError('The get method must be implemented by the feature repository.')
111
+
112
+ # * method: list
113
+ @abstractmethod
114
+ def list(self, group_id: str = None) -> List[Feature]:
115
+ '''
116
+ List the features.
117
+
118
+ :param group_id: The group id.
119
+ :type group_id: str
120
+ :return: The list of features.
121
+ :rtype: List[Feature]
122
+ '''
123
+ raise NotImplementedError('The list method must be implemented by the feature repository.')
124
+
125
+
126
+
127
+ # ** contract: feature_service
128
+ class FeatureService(Service):
129
+ '''
130
+ Feature service contract.
131
+ '''
132
+
133
+ # * method: parse_parameter
134
+ @abstractmethod
135
+ def parse_parameter(self, parameter: str, request: Request = None) -> str:
136
+ '''
137
+ Parse a parameter.
138
+
139
+ :param parameter: The parameter to parse.
140
+ :type parameter: str
141
+ :param request: The request object containing data for parameter parsing.
142
+ :type request: Request
143
+ :return: The parsed parameter.
144
+ :rtype : str
145
+ '''
146
+ raise NotImplementedError('The parse_parameter method must be implemented by the feature service.')
147
+
148
+ # * method: get_feature
149
+ @abstractmethod
150
+ def get_feature(self, feature_id: str) -> Feature:
151
+ '''
152
+ Get a feature by its ID.
153
+
154
+ :param feature_id: The ID of the feature to retrieve.
155
+ :type feature_id: str
156
+ :return: The feature object.
157
+ :rtype: Feature
158
+ '''
159
+ raise NotImplementedError('The get_feature method must be implemented by the feature service.')
@@ -0,0 +1,34 @@
1
+ # *** imports
2
+
3
+ # ** infra
4
+ from abc import ABC, abstractmethod
5
+
6
+
7
+ # *** classes
8
+
9
+
10
+ # ** class: model_contract
11
+ class ModelContract(ABC):
12
+ '''
13
+ The model contract interface as an abstract base class.
14
+ '''
15
+
16
+ pass
17
+
18
+
19
+ # ** class: repository
20
+ class Repository(ABC):
21
+ '''
22
+ The repository interface as an abstract base class.
23
+ '''
24
+
25
+ pass
26
+
27
+
28
+ # ** class: service
29
+ class Service(ABC):
30
+ '''
31
+ The service interface as an abstract base class.
32
+ '''
33
+
34
+ pass
tiferet/data/__init__.py CHANGED
@@ -1,5 +1,4 @@
1
- from typing import List, Dict
1
+ # *** imports
2
2
 
3
- from .error import *
4
- from .feature import *
5
- from .app import *
3
+ # ** app
4
+ from .settings import *