orionis 0.300.0__py3-none-any.whl → 0.302.0__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.
- orionis/metadata/framework.py +1 -1
- orionis/services/introspection/abstract/__init__.py +0 -0
- orionis/services/introspection/abstract/contracts/__init__.py +0 -0
- orionis/services/introspection/abstract/contracts/reflection_abstract.py +893 -0
- orionis/services/introspection/abstract/reflection_abstract.py +1266 -0
- orionis/services/introspection/concretes/contracts/__init__.py +0 -0
- orionis/services/introspection/concretes/contracts/reflection_concrete.py +997 -0
- orionis/services/introspection/concretes/reflection_concrete.py +23 -9
- orionis/services/introspection/instances/reflection_instance.py +4 -1
- orionis/services/introspection/modules/__init__.py +0 -0
- orionis/services/introspection/modules/contracts/__init__.py +0 -0
- orionis/services/introspection/modules/contracts/reflection_instance.py +380 -0
- orionis/services/introspection/modules/reflection_instance.py +500 -0
- {orionis-0.300.0.dist-info → orionis-0.302.0.dist-info}/METADATA +1 -1
- {orionis-0.300.0.dist-info → orionis-0.302.0.dist-info}/RECORD +21 -11
- tests/example/test_example.py +1 -1
- tests/support/inspection/fakes/fake_reflect_instance.py +237 -1
- {orionis-0.300.0.dist-info → orionis-0.302.0.dist-info}/WHEEL +0 -0
- {orionis-0.300.0.dist-info → orionis-0.302.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.300.0.dist-info → orionis-0.302.0.dist-info}/top_level.txt +0 -0
- {orionis-0.300.0.dist-info → orionis-0.302.0.dist-info}/zip-safe +0 -0
@@ -1,18 +1,18 @@
|
|
1
|
+
import abc
|
1
2
|
import inspect
|
2
3
|
import keyword
|
3
|
-
from typing import Any, Callable,
|
4
|
+
from typing import Any, Callable, List, Type
|
4
5
|
from orionis.services.asynchrony.coroutines import Coroutine
|
6
|
+
from orionis.services.introspection.concretes.contracts.reflection_concrete import IReflectionConcrete
|
5
7
|
from orionis.services.introspection.dependencies.entities.class_dependencies import ClassDependency
|
6
8
|
from orionis.services.introspection.dependencies.entities.method_dependencies import MethodDependency
|
7
9
|
from orionis.services.introspection.dependencies.reflect_dependencies import ReflectDependencies
|
8
10
|
from orionis.services.introspection.exceptions.reflection_attribute_error import ReflectionAttributeError
|
9
11
|
from orionis.services.introspection.exceptions.reflection_type_error import ReflectionTypeError
|
10
12
|
from orionis.services.introspection.exceptions.reflection_value_error import ReflectionValueError
|
11
|
-
import abc
|
12
|
-
|
13
13
|
from orionis.services.introspection.instances.reflection_instance import ReflectionInstance
|
14
14
|
|
15
|
-
class ReflectionConcrete:
|
15
|
+
class ReflectionConcrete(IReflectionConcrete):
|
16
16
|
|
17
17
|
def __init__(self, concrete: Type) -> None:
|
18
18
|
"""
|
@@ -88,7 +88,6 @@ class ReflectionConcrete:
|
|
88
88
|
instance = self._concrete(*args, **kwargs)
|
89
89
|
|
90
90
|
# Check if __str__ is a coroutine function
|
91
|
-
import inspect
|
92
91
|
str_method = getattr(instance, '__str__', None)
|
93
92
|
if str_method and inspect.iscoroutinefunction(str_method):
|
94
93
|
raise ReflectionValueError(
|
@@ -186,7 +185,6 @@ class ReflectionConcrete:
|
|
186
185
|
ReflectionValueError
|
187
186
|
If the source code cannot be retrieved.
|
188
187
|
"""
|
189
|
-
import inspect
|
190
188
|
try:
|
191
189
|
return inspect.getsource(self._concrete)
|
192
190
|
except OSError as e:
|
@@ -206,7 +204,6 @@ class ReflectionConcrete:
|
|
206
204
|
ReflectionValueError
|
207
205
|
If the file path cannot be retrieved.
|
208
206
|
"""
|
209
|
-
import inspect
|
210
207
|
try:
|
211
208
|
return inspect.getfile(self._concrete)
|
212
209
|
except TypeError as e:
|
@@ -221,7 +218,10 @@ class ReflectionConcrete:
|
|
221
218
|
dict
|
222
219
|
A dictionary of type annotations.
|
223
220
|
"""
|
224
|
-
|
221
|
+
annotations = {}
|
222
|
+
for k, v in getattr(self._concrete, '__annotations__', {}).items():
|
223
|
+
annotations[str(k).replace(f"_{self.getClassName()}", "")] = v
|
224
|
+
return annotations
|
225
225
|
|
226
226
|
def hasAttribute(self, attribute: str) -> bool:
|
227
227
|
"""
|
@@ -1441,4 +1441,18 @@ class ReflectionConcrete:
|
|
1441
1441
|
method_name = f"_{class_name}{method_name}"
|
1442
1442
|
|
1443
1443
|
# Use ReflectDependencies to get method dependencies
|
1444
|
-
return ReflectDependencies(self._concrete).getMethodDependencies(method_name)
|
1444
|
+
return ReflectDependencies(self._concrete).getMethodDependencies(method_name)
|
1445
|
+
|
1446
|
+
def reflectionInstance(self) -> ReflectionInstance:
|
1447
|
+
"""
|
1448
|
+
Get the reflection instance of the concrete class.
|
1449
|
+
|
1450
|
+
Returns
|
1451
|
+
-------
|
1452
|
+
ReflectionInstance
|
1453
|
+
An instance of ReflectionInstance for the concrete class
|
1454
|
+
"""
|
1455
|
+
if not self.__instance:
|
1456
|
+
raise ReflectionValueError(f"Instance of class '{self.getClassName()}' is not initialized. Use getInstance() to create an instance before calling methods.")
|
1457
|
+
|
1458
|
+
return ReflectionInstance(self.__instance)
|
@@ -157,7 +157,10 @@ class ReflectionInstance(IReflectionInstance):
|
|
157
157
|
Dict[str, Any]
|
158
158
|
Dictionary of attribute names and their type annotations
|
159
159
|
"""
|
160
|
-
|
160
|
+
annotations = {}
|
161
|
+
for k, v in self._instance.__annotations__.items():
|
162
|
+
annotations[str(k).replace(f"_{self.getClassName()}", "")] = v
|
163
|
+
return annotations
|
161
164
|
|
162
165
|
def hasAttribute(self, name: str) -> bool:
|
163
166
|
"""
|
File without changes
|
File without changes
|
@@ -0,0 +1,380 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
|
3
|
+
class IReflectionModule(ABC):
|
4
|
+
|
5
|
+
@abstractmethod
|
6
|
+
def getModule(self):
|
7
|
+
"""
|
8
|
+
Returns the module object.
|
9
|
+
|
10
|
+
Returns
|
11
|
+
-------
|
12
|
+
module
|
13
|
+
The imported module object.
|
14
|
+
"""
|
15
|
+
pass
|
16
|
+
|
17
|
+
@abstractmethod
|
18
|
+
def hasClass(self, class_name: str) -> bool:
|
19
|
+
"""
|
20
|
+
Check if the module contains a class with the specified name.
|
21
|
+
|
22
|
+
Parameters
|
23
|
+
----------
|
24
|
+
class_name : str
|
25
|
+
The name of the class to check for.
|
26
|
+
|
27
|
+
Returns
|
28
|
+
-------
|
29
|
+
bool
|
30
|
+
True if the class exists in the module, False otherwise.
|
31
|
+
"""
|
32
|
+
pass
|
33
|
+
|
34
|
+
@abstractmethod
|
35
|
+
def getClass(self, class_name: str):
|
36
|
+
"""
|
37
|
+
Get a class by its name from the module.
|
38
|
+
|
39
|
+
Parameters
|
40
|
+
----------
|
41
|
+
class_name : str
|
42
|
+
The name of the class to retrieve.
|
43
|
+
|
44
|
+
Returns
|
45
|
+
-------
|
46
|
+
type
|
47
|
+
The class object if found, None otherwise.
|
48
|
+
"""
|
49
|
+
pass
|
50
|
+
|
51
|
+
@abstractmethod
|
52
|
+
def setClass(self, class_name: str, cls: type) -> bool:
|
53
|
+
"""
|
54
|
+
Set a class in the module.
|
55
|
+
|
56
|
+
Parameters
|
57
|
+
----------
|
58
|
+
class_name : str
|
59
|
+
The name of the class to set.
|
60
|
+
cls : type
|
61
|
+
The class object to set.
|
62
|
+
|
63
|
+
Raises
|
64
|
+
------
|
65
|
+
ValueError
|
66
|
+
If `cls` is not a class or if `class_name` is not a valid identifier.
|
67
|
+
"""
|
68
|
+
pass
|
69
|
+
|
70
|
+
@abstractmethod
|
71
|
+
def removeClass(self, class_name: str) -> bool:
|
72
|
+
"""
|
73
|
+
Remove a class from the module.
|
74
|
+
|
75
|
+
Parameters
|
76
|
+
----------
|
77
|
+
class_name : str
|
78
|
+
The name of the class to remove.
|
79
|
+
|
80
|
+
Raises
|
81
|
+
------
|
82
|
+
ValueError
|
83
|
+
If `class_name` is not a valid identifier or if the class does not exist.
|
84
|
+
"""
|
85
|
+
pass
|
86
|
+
|
87
|
+
@abstractmethod
|
88
|
+
def initClass(self, class_name: str, *args, **kwargs):
|
89
|
+
"""
|
90
|
+
Initialize a class from the module with the given arguments.
|
91
|
+
|
92
|
+
Parameters
|
93
|
+
----------
|
94
|
+
class_name : str
|
95
|
+
The name of the class to initialize.
|
96
|
+
*args
|
97
|
+
Positional arguments to pass to the class constructor.
|
98
|
+
**kwargs
|
99
|
+
Keyword arguments to pass to the class constructor.
|
100
|
+
|
101
|
+
Returns
|
102
|
+
-------
|
103
|
+
object
|
104
|
+
An instance of the class initialized with the provided arguments.
|
105
|
+
|
106
|
+
Raises
|
107
|
+
------
|
108
|
+
ReflectionValueError
|
109
|
+
If the class does not exist or if the class name is not a valid identifier.
|
110
|
+
"""
|
111
|
+
pass
|
112
|
+
|
113
|
+
@abstractmethod
|
114
|
+
def getClasses(self) -> dict:
|
115
|
+
"""
|
116
|
+
Returns a dictionary of classes defined in the module.
|
117
|
+
|
118
|
+
Returns
|
119
|
+
-------
|
120
|
+
dict
|
121
|
+
A dictionary where keys are class names and values are class objects.
|
122
|
+
"""
|
123
|
+
pass
|
124
|
+
|
125
|
+
@abstractmethod
|
126
|
+
def getPublicClasses(self) -> dict:
|
127
|
+
"""
|
128
|
+
Returns a dictionary of public classes defined in the module.
|
129
|
+
|
130
|
+
Returns
|
131
|
+
-------
|
132
|
+
dict
|
133
|
+
A dictionary where keys are class names and values are class objects.
|
134
|
+
"""
|
135
|
+
pass
|
136
|
+
|
137
|
+
@abstractmethod
|
138
|
+
def getProtectedClasses(self) -> dict:
|
139
|
+
"""
|
140
|
+
Returns a dictionary of protected classes defined in the module.
|
141
|
+
|
142
|
+
Returns
|
143
|
+
-------
|
144
|
+
dict
|
145
|
+
A dictionary where keys are class names and values are class objects.
|
146
|
+
"""
|
147
|
+
pass
|
148
|
+
|
149
|
+
@abstractmethod
|
150
|
+
def getPrivateClasses(self) -> dict:
|
151
|
+
"""
|
152
|
+
Returns a dictionary of private classes defined in the module.
|
153
|
+
|
154
|
+
Returns
|
155
|
+
-------
|
156
|
+
dict
|
157
|
+
A dictionary where keys are class names and values are class objects.
|
158
|
+
"""
|
159
|
+
pass
|
160
|
+
|
161
|
+
@abstractmethod
|
162
|
+
def getConstant(self, constant_name: str):
|
163
|
+
"""
|
164
|
+
Get a constant by its name from the module.
|
165
|
+
|
166
|
+
Parameters
|
167
|
+
----------
|
168
|
+
constant_name : str
|
169
|
+
The name of the constant to retrieve.
|
170
|
+
|
171
|
+
Returns
|
172
|
+
-------
|
173
|
+
Any
|
174
|
+
The value of the constant if found, None otherwise.
|
175
|
+
"""
|
176
|
+
pass
|
177
|
+
|
178
|
+
@abstractmethod
|
179
|
+
def getConstants(self) -> dict:
|
180
|
+
"""
|
181
|
+
Returns a dictionary of constants defined in the module.
|
182
|
+
|
183
|
+
Returns
|
184
|
+
-------
|
185
|
+
dict
|
186
|
+
A dictionary where keys are constant names and values are their values.
|
187
|
+
"""
|
188
|
+
pass
|
189
|
+
|
190
|
+
@abstractmethod
|
191
|
+
def getPublicConstants(self) -> dict:
|
192
|
+
"""
|
193
|
+
Returns a dictionary of public constants defined in the module.
|
194
|
+
|
195
|
+
Returns
|
196
|
+
-------
|
197
|
+
dict
|
198
|
+
A dictionary where keys are constant names and values are their values.
|
199
|
+
"""
|
200
|
+
pass
|
201
|
+
|
202
|
+
@abstractmethod
|
203
|
+
def getProtectedConstants(self) -> dict:
|
204
|
+
"""
|
205
|
+
Returns a dictionary of protected constants defined in the module.
|
206
|
+
|
207
|
+
Returns
|
208
|
+
-------
|
209
|
+
dict
|
210
|
+
A dictionary where keys are constant names and values are their values.
|
211
|
+
"""
|
212
|
+
pass
|
213
|
+
|
214
|
+
@abstractmethod
|
215
|
+
def getPrivateConstants(self) -> dict:
|
216
|
+
"""
|
217
|
+
Returns a dictionary of private constants defined in the module.
|
218
|
+
|
219
|
+
Returns
|
220
|
+
-------
|
221
|
+
dict
|
222
|
+
A dictionary where keys are constant names and values are their values.
|
223
|
+
"""
|
224
|
+
pass
|
225
|
+
|
226
|
+
@abstractmethod
|
227
|
+
def getFunctions(self) -> dict:
|
228
|
+
"""
|
229
|
+
Returns a dictionary of functions defined in the module.
|
230
|
+
|
231
|
+
Returns
|
232
|
+
-------
|
233
|
+
dict
|
234
|
+
A dictionary where keys are function names and values are function objects.
|
235
|
+
"""
|
236
|
+
pass
|
237
|
+
|
238
|
+
@abstractmethod
|
239
|
+
def getPublicFunctions(self) -> dict:
|
240
|
+
"""
|
241
|
+
Returns a dictionary of public functions defined in the module.
|
242
|
+
|
243
|
+
Returns
|
244
|
+
-------
|
245
|
+
dict
|
246
|
+
A dictionary where keys are function names and values are function objects.
|
247
|
+
"""
|
248
|
+
pass
|
249
|
+
|
250
|
+
@abstractmethod
|
251
|
+
def getPublicSyncFunctions(self) -> dict:
|
252
|
+
"""
|
253
|
+
Returns a dictionary of public synchronous functions defined in the module.
|
254
|
+
|
255
|
+
Returns
|
256
|
+
-------
|
257
|
+
dict
|
258
|
+
A dictionary where keys are function names and values are function objects.
|
259
|
+
"""
|
260
|
+
pass
|
261
|
+
|
262
|
+
@abstractmethod
|
263
|
+
def getPublicAsyncFunctions(self) -> dict:
|
264
|
+
"""
|
265
|
+
Returns a dictionary of public asynchronous functions defined in the module.
|
266
|
+
|
267
|
+
Returns
|
268
|
+
-------
|
269
|
+
dict
|
270
|
+
A dictionary where keys are function names and values are function objects.
|
271
|
+
"""
|
272
|
+
pass
|
273
|
+
|
274
|
+
@abstractmethod
|
275
|
+
def getProtectedFunctions(self) -> dict:
|
276
|
+
"""
|
277
|
+
Returns a dictionary of protected functions defined in the module.
|
278
|
+
|
279
|
+
Returns
|
280
|
+
-------
|
281
|
+
dict
|
282
|
+
A dictionary where keys are function names and values are function objects.
|
283
|
+
"""
|
284
|
+
pass
|
285
|
+
|
286
|
+
@abstractmethod
|
287
|
+
def getProtectedSyncFunctions(self) -> dict:
|
288
|
+
"""
|
289
|
+
Returns a dictionary of protected synchronous functions defined in the module.
|
290
|
+
|
291
|
+
Returns
|
292
|
+
-------
|
293
|
+
dict
|
294
|
+
A dictionary where keys are function names and values are function objects.
|
295
|
+
"""
|
296
|
+
pass
|
297
|
+
|
298
|
+
@abstractmethod
|
299
|
+
def getProtectedAsyncFunctions(self) -> dict:
|
300
|
+
"""
|
301
|
+
Returns a dictionary of protected asynchronous functions defined in the module.
|
302
|
+
|
303
|
+
Returns
|
304
|
+
-------
|
305
|
+
dict
|
306
|
+
A dictionary where keys are function names and values are function objects.
|
307
|
+
"""
|
308
|
+
pass
|
309
|
+
|
310
|
+
@abstractmethod
|
311
|
+
def getPrivateFunctions(self) -> dict:
|
312
|
+
"""
|
313
|
+
Returns a dictionary of private functions defined in the module.
|
314
|
+
|
315
|
+
Returns
|
316
|
+
-------
|
317
|
+
dict
|
318
|
+
A dictionary where keys are function names and values are function objects.
|
319
|
+
"""
|
320
|
+
pass
|
321
|
+
|
322
|
+
@abstractmethod
|
323
|
+
def getPrivateSyncFunctions(self) -> dict:
|
324
|
+
"""
|
325
|
+
Returns a dictionary of private synchronous functions defined in the module.
|
326
|
+
|
327
|
+
Returns
|
328
|
+
-------
|
329
|
+
dict
|
330
|
+
A dictionary where keys are function names and values are function objects.
|
331
|
+
"""
|
332
|
+
pass
|
333
|
+
|
334
|
+
@abstractmethod
|
335
|
+
def getPrivateAsyncFunctions(self) -> dict:
|
336
|
+
"""
|
337
|
+
Returns a dictionary of private asynchronous functions defined in the module.
|
338
|
+
|
339
|
+
Returns
|
340
|
+
-------
|
341
|
+
dict
|
342
|
+
A dictionary where keys are function names and values are function objects.
|
343
|
+
"""
|
344
|
+
pass
|
345
|
+
|
346
|
+
@abstractmethod
|
347
|
+
def getImports(self) -> dict:
|
348
|
+
"""
|
349
|
+
Returns a dictionary of imported modules in the module.
|
350
|
+
|
351
|
+
Returns
|
352
|
+
-------
|
353
|
+
dict
|
354
|
+
A dictionary where keys are import names and values are module objects.
|
355
|
+
"""
|
356
|
+
pass
|
357
|
+
|
358
|
+
@abstractmethod
|
359
|
+
def getFile(self) -> str:
|
360
|
+
"""
|
361
|
+
Returns the file name of the module.
|
362
|
+
|
363
|
+
Returns
|
364
|
+
-------
|
365
|
+
str
|
366
|
+
The file name of the module.
|
367
|
+
"""
|
368
|
+
pass
|
369
|
+
|
370
|
+
@abstractmethod
|
371
|
+
def getSourceCode(self) -> str:
|
372
|
+
"""
|
373
|
+
Returns the source code of the module.
|
374
|
+
|
375
|
+
Returns
|
376
|
+
-------
|
377
|
+
str
|
378
|
+
The source code of the module.
|
379
|
+
"""
|
380
|
+
pass
|