orionis 0.231.0__py3-none-any.whl → 0.232.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/framework.py +1 -1
- orionis/luminate/support/inspection/reflexion_instance.py +265 -158
- {orionis-0.231.0.dist-info → orionis-0.232.0.dist-info}/METADATA +1 -1
- {orionis-0.231.0.dist-info → orionis-0.232.0.dist-info}/RECORD +10 -10
- tests/support/inspection/fakes/fake_reflection_instance.py +20 -29
- tests/support/inspection/test_reflection_instance.py +105 -20
- {orionis-0.231.0.dist-info → orionis-0.232.0.dist-info}/LICENCE +0 -0
- {orionis-0.231.0.dist-info → orionis-0.232.0.dist-info}/WHEEL +0 -0
- {orionis-0.231.0.dist-info → orionis-0.232.0.dist-info}/entry_points.txt +0 -0
- {orionis-0.231.0.dist-info → orionis-0.232.0.dist-info}/top_level.txt +0 -0
orionis/framework.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
from typing import Any, Type, Dict, List, Tuple, Callable, Optional
|
2
2
|
import inspect
|
3
3
|
|
4
|
+
from orionis.luminate.support.asynchrony.async_io import AsyncIO
|
5
|
+
|
4
6
|
class ReflexionInstance:
|
5
7
|
"""A reflection object encapsulating a class instance.
|
6
8
|
|
@@ -26,13 +28,6 @@ class ReflexionInstance:
|
|
26
28
|
-------
|
27
29
|
str
|
28
30
|
The name of the class
|
29
|
-
|
30
|
-
Examples
|
31
|
-
--------
|
32
|
-
>>> obj = SomeClass()
|
33
|
-
>>> reflex = ReflexionInstance(obj)
|
34
|
-
>>> reflex.getClassName()
|
35
|
-
'SomeClass'
|
36
31
|
"""
|
37
32
|
return self._instance.__class__.__name__
|
38
33
|
|
@@ -43,11 +38,6 @@ class ReflexionInstance:
|
|
43
38
|
-------
|
44
39
|
Type
|
45
40
|
The class object of the instance
|
46
|
-
|
47
|
-
Examples
|
48
|
-
--------
|
49
|
-
>>> reflex.getClass() is SomeClass
|
50
|
-
True
|
51
41
|
"""
|
52
42
|
return self._instance.__class__
|
53
43
|
|
@@ -58,11 +48,6 @@ class ReflexionInstance:
|
|
58
48
|
-------
|
59
49
|
str
|
60
50
|
The module name
|
61
|
-
|
62
|
-
Examples
|
63
|
-
--------
|
64
|
-
>>> reflex.getModuleName()
|
65
|
-
'some_module'
|
66
51
|
"""
|
67
52
|
return self._instance.__class__.__module__
|
68
53
|
|
@@ -73,11 +58,6 @@ class ReflexionInstance:
|
|
73
58
|
-------
|
74
59
|
Dict[str, Any]
|
75
60
|
Dictionary of attribute names and their values
|
76
|
-
|
77
|
-
Examples
|
78
|
-
--------
|
79
|
-
>>> reflex.getAttributes()
|
80
|
-
{'attr1': value1, 'attr2': value2}
|
81
61
|
"""
|
82
62
|
return vars(self._instance)
|
83
63
|
|
@@ -88,41 +68,165 @@ class ReflexionInstance:
|
|
88
68
|
-------
|
89
69
|
List[str]
|
90
70
|
List of method names
|
71
|
+
"""
|
72
|
+
class_name = self.getClassName()
|
73
|
+
methods = [name for name, _ in inspect.getmembers(
|
74
|
+
self._instance,
|
75
|
+
predicate=inspect.ismethod
|
76
|
+
)]
|
77
|
+
|
78
|
+
out_methods = []
|
79
|
+
for method in methods:
|
80
|
+
out_methods.append(method.replace(f"_{class_name}", ""))
|
81
|
+
|
82
|
+
return out_methods
|
83
|
+
|
84
|
+
def getProtectedMethods(self) -> List[str]:
|
85
|
+
"""Get all protected method names of the instance.
|
91
86
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
87
|
+
Returns
|
88
|
+
-------
|
89
|
+
List[str]
|
90
|
+
List of protected method names, excluding private methods (starting with '_')
|
96
91
|
"""
|
97
|
-
|
92
|
+
class_name = self.getClassName()
|
93
|
+
methods = [name for name, _ in inspect.getmembers(
|
98
94
|
self._instance,
|
99
95
|
predicate=inspect.ismethod
|
100
96
|
)]
|
101
97
|
|
98
|
+
out_methods = []
|
99
|
+
for method in methods:
|
100
|
+
if method.startswith("_") and not method.startswith("__") and not method.startswith(f"_{class_name}"):
|
101
|
+
out_methods.append(method)
|
102
|
+
|
103
|
+
return out_methods
|
104
|
+
|
105
|
+
def getPrivateMethods(self) -> List[str]:
|
106
|
+
"""Get all private method names of the instance.
|
107
|
+
|
108
|
+
Returns
|
109
|
+
-------
|
110
|
+
List[str]
|
111
|
+
List of private method names, excluding protected methods (starting with '_')
|
112
|
+
"""
|
113
|
+
class_name = self.getClassName()
|
114
|
+
methods = [name for name, _ in inspect.getmembers(
|
115
|
+
self._instance,
|
116
|
+
predicate=inspect.ismethod
|
117
|
+
)]
|
118
|
+
|
119
|
+
out_methods = []
|
120
|
+
for method in methods:
|
121
|
+
if method.startswith(f"_{class_name}"):
|
122
|
+
out_methods.append(method.replace(f"_{class_name}", ""))
|
123
|
+
|
124
|
+
return out_methods
|
125
|
+
|
126
|
+
def getAsyncMethods(self) -> List[str]:
|
127
|
+
"""
|
128
|
+
Get all asynchronous method names of the instance that are not static methods.
|
129
|
+
|
130
|
+
Returns
|
131
|
+
-------
|
132
|
+
List[str]
|
133
|
+
List of asynchronous method names
|
134
|
+
"""
|
135
|
+
obj = self._instance
|
136
|
+
cls = obj if inspect.isclass(obj) else obj.__class__
|
137
|
+
class_name = self.getClassName()
|
138
|
+
methods = [
|
139
|
+
name for name, func in inspect.getmembers(obj, inspect.iscoroutinefunction)
|
140
|
+
if not isinstance(inspect.getattr_static(cls, name, None), staticmethod)
|
141
|
+
]
|
142
|
+
|
143
|
+
out_methods = []
|
144
|
+
for method in methods:
|
145
|
+
out_methods.append(method.replace(f"_{class_name}", ""))
|
146
|
+
|
147
|
+
return out_methods
|
148
|
+
|
149
|
+
def getSyncMethods(self) -> List[str]:
|
150
|
+
"""
|
151
|
+
Get all synchronous method names of the instance that are not static methods.
|
152
|
+
|
153
|
+
Returns
|
154
|
+
-------
|
155
|
+
List[str]
|
156
|
+
List of synchronous method names
|
157
|
+
"""
|
158
|
+
obj = self._instance
|
159
|
+
cls = obj if inspect.isclass(obj) else obj.__class__
|
160
|
+
class_name = self.getClassName()
|
161
|
+
methods = [
|
162
|
+
name for name, func in inspect.getmembers(obj, predicate=inspect.ismethod)
|
163
|
+
if not inspect.iscoroutinefunction(func) and
|
164
|
+
not isinstance(inspect.getattr_static(cls, name, None), staticmethod)
|
165
|
+
]
|
166
|
+
|
167
|
+
out_methods = []
|
168
|
+
for method in methods:
|
169
|
+
out_methods.append(method.replace(f"_{class_name}", ""))
|
170
|
+
|
171
|
+
return out_methods
|
172
|
+
|
173
|
+
def getClassMethods(self) -> List[str]:
|
174
|
+
"""Get all class method names of the instance.
|
175
|
+
|
176
|
+
Returns
|
177
|
+
-------
|
178
|
+
List[str]
|
179
|
+
List of class method names.
|
180
|
+
"""
|
181
|
+
return [
|
182
|
+
name for name in dir(self._instance.__class__)
|
183
|
+
if isinstance(inspect.getattr_static(self._instance.__class__, name), classmethod)
|
184
|
+
]
|
185
|
+
|
102
186
|
def getStaticMethods(self) -> List[str]:
|
103
187
|
"""Get all static method names of the instance.
|
104
188
|
|
105
189
|
Returns
|
106
190
|
-------
|
107
191
|
List[str]
|
108
|
-
List of static method names
|
109
|
-
|
110
|
-
Examples
|
111
|
-
--------
|
112
|
-
>>> class MyClass:
|
113
|
-
... @staticmethod
|
114
|
-
... def static_method(): pass
|
115
|
-
... @staticmethod
|
116
|
-
... def _private_static(): pass
|
117
|
-
...
|
118
|
-
>>> reflex = ReflexionInstance(MyClass())
|
119
|
-
>>> reflex.getStaticMethods()
|
120
|
-
['static_method']
|
192
|
+
List of static method names.
|
121
193
|
"""
|
122
194
|
return [
|
123
195
|
name for name in dir(self._instance.__class__)
|
124
|
-
if
|
125
|
-
|
196
|
+
if isinstance(inspect.getattr_static(self._instance.__class__, name), staticmethod)
|
197
|
+
]
|
198
|
+
|
199
|
+
def getAsyncStaticMethods(self) -> List[str]:
|
200
|
+
"""
|
201
|
+
Get all asynchronous method names of the instance that are not static methods.
|
202
|
+
|
203
|
+
Returns
|
204
|
+
-------
|
205
|
+
List[str]
|
206
|
+
List of asynchronous method names
|
207
|
+
"""
|
208
|
+
obj = self._instance
|
209
|
+
cls = obj if inspect.isclass(obj) else obj.__class__
|
210
|
+
return [
|
211
|
+
name for name, func in inspect.getmembers(obj, inspect.iscoroutinefunction)
|
212
|
+
if isinstance(inspect.getattr_static(cls, name, None), staticmethod)
|
213
|
+
]
|
214
|
+
|
215
|
+
def getSyncStaticMethods(self) -> List[str]:
|
216
|
+
"""
|
217
|
+
Get all synchronous static method names of the instance.
|
218
|
+
|
219
|
+
Returns
|
220
|
+
-------
|
221
|
+
List[str]
|
222
|
+
List of synchronous static method names
|
223
|
+
"""
|
224
|
+
obj = self._instance
|
225
|
+
cls = obj if inspect.isclass(obj) else obj.__class__
|
226
|
+
return [
|
227
|
+
name for name, func in inspect.getmembers(cls, inspect.isfunction)
|
228
|
+
if not inspect.iscoroutinefunction(func) and
|
229
|
+
isinstance(inspect.getattr_static(cls, name, None), staticmethod)
|
126
230
|
]
|
127
231
|
|
128
232
|
def getPropertyNames(self) -> List[str]:
|
@@ -132,103 +236,117 @@ class ReflexionInstance:
|
|
132
236
|
-------
|
133
237
|
List[str]
|
134
238
|
List of property names
|
135
|
-
|
136
|
-
Examples
|
137
|
-
--------
|
138
|
-
>>> reflex.getPropertyNames()
|
139
|
-
['prop1', 'prop2']
|
140
239
|
"""
|
141
240
|
return [name for name, _ in inspect.getmembers(
|
142
241
|
self._instance.__class__,
|
143
242
|
lambda x: isinstance(x, property)
|
144
243
|
)]
|
145
244
|
|
146
|
-
def
|
147
|
-
"""
|
245
|
+
def getProperty(self, propertyName: str) -> Any:
|
246
|
+
"""Get the value of a property.
|
148
247
|
|
149
248
|
Parameters
|
150
249
|
----------
|
151
|
-
|
152
|
-
Name of the
|
153
|
-
*args : Any
|
154
|
-
Positional arguments for the method
|
155
|
-
**kwargs : Any
|
156
|
-
Keyword arguments for the method
|
250
|
+
propertyName : str
|
251
|
+
Name of the property
|
157
252
|
|
158
253
|
Returns
|
159
254
|
-------
|
160
255
|
Any
|
161
|
-
The
|
256
|
+
The value of the property
|
162
257
|
|
163
258
|
Raises
|
164
259
|
------
|
165
260
|
AttributeError
|
166
|
-
If the
|
167
|
-
|
168
|
-
Examples
|
169
|
-
--------
|
170
|
-
>>> reflex.callMethod('calculate', 2, 3)
|
171
|
-
5
|
261
|
+
If the property doesn't exist or is not a property
|
172
262
|
"""
|
173
|
-
|
174
|
-
|
263
|
+
attr = getattr(self._instance.__class__, propertyName, None)
|
264
|
+
if isinstance(attr, property) and attr.fget is not None:
|
265
|
+
return getattr(self._instance, propertyName)
|
266
|
+
raise AttributeError(f"{propertyName} is not a property or doesn't have a getter.")
|
175
267
|
|
176
|
-
def
|
177
|
-
"""Get the signature of a
|
268
|
+
def getPropertySignature(self, propertyName: str) -> inspect.Signature:
|
269
|
+
"""Get the signature of a property.
|
178
270
|
|
179
271
|
Parameters
|
180
272
|
----------
|
181
|
-
|
182
|
-
Name of the
|
273
|
+
propertyName : str
|
274
|
+
Name of the property
|
183
275
|
|
184
276
|
Returns
|
185
277
|
-------
|
186
278
|
inspect.Signature
|
187
|
-
The
|
279
|
+
The property signature
|
188
280
|
|
189
281
|
Raises
|
190
282
|
------
|
191
283
|
AttributeError
|
192
|
-
If the
|
193
|
-
|
194
|
-
Examples
|
195
|
-
--------
|
196
|
-
>>> sig = reflex.getMethodSignature('calculate')
|
197
|
-
>>> str(sig)
|
198
|
-
'(x, y)'
|
284
|
+
If the property doesn't exist or is not a property
|
199
285
|
"""
|
200
|
-
|
201
|
-
if
|
202
|
-
return inspect.signature(
|
286
|
+
attr = getattr(self._instance.__class__, propertyName, None)
|
287
|
+
if isinstance(attr, property) and attr.fget is not None:
|
288
|
+
return inspect.signature(attr.fget)
|
289
|
+
raise AttributeError(f"{propertyName} is not a property or doesn't have a getter.")
|
203
290
|
|
204
|
-
def
|
205
|
-
"""
|
291
|
+
def callMethod(self, methodName: str, *args: Any, **kwargs: Any) -> Any:
|
292
|
+
"""Call a method on the instance.
|
206
293
|
|
207
294
|
Parameters
|
208
295
|
----------
|
209
|
-
|
210
|
-
Name of the
|
296
|
+
methodName : str
|
297
|
+
Name of the method to call
|
298
|
+
*args : Any
|
299
|
+
Positional arguments for the method
|
300
|
+
**kwargs : Any
|
301
|
+
Keyword arguments for the method
|
211
302
|
|
212
303
|
Returns
|
213
304
|
-------
|
214
|
-
|
215
|
-
The
|
305
|
+
Any
|
306
|
+
The result of the method call
|
216
307
|
|
217
308
|
Raises
|
218
309
|
------
|
219
310
|
AttributeError
|
220
|
-
If the
|
311
|
+
If the method does not exist on the instance
|
312
|
+
TypeError
|
313
|
+
If the method is not callable
|
314
|
+
"""
|
315
|
+
|
316
|
+
if methodName in self.getPrivateMethods():
|
317
|
+
methodName = f"_{self.getClassName()}{methodName}"
|
318
|
+
|
319
|
+
method = getattr(self._instance, methodName, None)
|
320
|
+
|
321
|
+
if method is None:
|
322
|
+
raise AttributeError(f"'{self.getClassName()}' object has no method '{methodName}'.")
|
323
|
+
if not callable(method):
|
324
|
+
raise TypeError(f"'{methodName}' is not callable on '{self.getClassName()}'.")
|
325
|
+
|
326
|
+
if inspect.iscoroutinefunction(method):
|
327
|
+
return AsyncIO.run(method(*args, **kwargs))
|
328
|
+
|
329
|
+
return method(*args, **kwargs)
|
221
330
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
331
|
+
def getMethodSignature(self, methodName: str) -> inspect.Signature:
|
332
|
+
"""Get the signature of a method.
|
333
|
+
|
334
|
+
Parameters
|
335
|
+
----------
|
336
|
+
methodName : str
|
337
|
+
Name of the method
|
338
|
+
|
339
|
+
Returns
|
340
|
+
-------
|
341
|
+
inspect.Signature
|
342
|
+
The method signature
|
227
343
|
"""
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
344
|
+
if methodName in self.getPrivateMethods():
|
345
|
+
methodName = f"_{self.getClassName()}{methodName}"
|
346
|
+
|
347
|
+
method = getattr(self._instance, methodName)
|
348
|
+
if callable(method):
|
349
|
+
return inspect.signature(method)
|
232
350
|
|
233
351
|
def getDocstring(self) -> Optional[str]:
|
234
352
|
"""Get the docstring of the instance's class.
|
@@ -237,11 +355,6 @@ class ReflexionInstance:
|
|
237
355
|
-------
|
238
356
|
Optional[str]
|
239
357
|
The class docstring, or None if not available
|
240
|
-
|
241
|
-
Examples
|
242
|
-
--------
|
243
|
-
>>> reflex.getDocstring()
|
244
|
-
'This class does something important.'
|
245
358
|
"""
|
246
359
|
return self._instance.__class__.__doc__
|
247
360
|
|
@@ -252,11 +365,6 @@ class ReflexionInstance:
|
|
252
365
|
-------
|
253
366
|
Tuple[Type, ...]
|
254
367
|
Tuple of base classes
|
255
|
-
|
256
|
-
Examples
|
257
|
-
--------
|
258
|
-
>>> reflex.getBaseClasses()
|
259
|
-
(<class 'object'>,)
|
260
368
|
"""
|
261
369
|
return self._instance.__class__.__bases__
|
262
370
|
|
@@ -272,11 +380,6 @@ class ReflexionInstance:
|
|
272
380
|
-------
|
273
381
|
bool
|
274
382
|
True if the instance is of the specified class
|
275
|
-
|
276
|
-
Examples
|
277
|
-
--------
|
278
|
-
>>> reflex.isInstanceOf(SomeClass)
|
279
|
-
True
|
280
383
|
"""
|
281
384
|
return isinstance(self._instance, cls)
|
282
385
|
|
@@ -287,13 +390,6 @@ class ReflexionInstance:
|
|
287
390
|
-------
|
288
391
|
Optional[str]
|
289
392
|
The source code if available, None otherwise
|
290
|
-
|
291
|
-
Examples
|
292
|
-
--------
|
293
|
-
>>> print(reflex.getSourceCode())
|
294
|
-
class SomeClass:
|
295
|
-
def __init__(self):
|
296
|
-
...
|
297
393
|
"""
|
298
394
|
try:
|
299
395
|
return inspect.getsource(self._instance.__class__)
|
@@ -307,11 +403,6 @@ class ReflexionInstance:
|
|
307
403
|
-------
|
308
404
|
Optional[str]
|
309
405
|
The file path if available, None otherwise
|
310
|
-
|
311
|
-
Examples
|
312
|
-
--------
|
313
|
-
>>> reflex.getFileLocation()
|
314
|
-
'/path/to/module.py'
|
315
406
|
"""
|
316
407
|
try:
|
317
408
|
return inspect.getfile(self._instance.__class__)
|
@@ -325,11 +416,6 @@ class ReflexionInstance:
|
|
325
416
|
-------
|
326
417
|
Dict[str, Any]
|
327
418
|
Dictionary of attribute names and their type annotations
|
328
|
-
|
329
|
-
Examples
|
330
|
-
--------
|
331
|
-
>>> reflex.getAnnotations()
|
332
|
-
{'name': str, 'value': int}
|
333
419
|
"""
|
334
420
|
return self._instance.__class__.__annotations__
|
335
421
|
|
@@ -345,11 +431,6 @@ class ReflexionInstance:
|
|
345
431
|
-------
|
346
432
|
bool
|
347
433
|
True if the attribute exists
|
348
|
-
|
349
|
-
Examples
|
350
|
-
--------
|
351
|
-
>>> reflex.hasAttribute('important_attr')
|
352
|
-
True
|
353
434
|
"""
|
354
435
|
return hasattr(self._instance, name)
|
355
436
|
|
@@ -370,11 +451,6 @@ class ReflexionInstance:
|
|
370
451
|
------
|
371
452
|
AttributeError
|
372
453
|
If the attribute doesn't exist
|
373
|
-
|
374
|
-
Examples
|
375
|
-
--------
|
376
|
-
>>> reflex.getAttribute('count')
|
377
|
-
42
|
378
454
|
"""
|
379
455
|
return getattr(self._instance, name)
|
380
456
|
|
@@ -392,29 +468,60 @@ class ReflexionInstance:
|
|
392
468
|
------
|
393
469
|
AttributeError
|
394
470
|
If the attribute is read-only
|
471
|
+
"""
|
472
|
+
if callable(value):
|
473
|
+
raise AttributeError(f"Cannot set attribute '{name}' to a callable.")
|
474
|
+
setattr(self._instance, name, value)
|
395
475
|
|
396
|
-
|
397
|
-
|
398
|
-
|
476
|
+
def removeAttribute(self, name: str) -> None:
|
477
|
+
"""Remove an attribute from the instance.
|
478
|
+
|
479
|
+
Parameters
|
480
|
+
----------
|
481
|
+
name : str
|
482
|
+
The attribute name to remove
|
483
|
+
|
484
|
+
Raises
|
485
|
+
------
|
486
|
+
AttributeError
|
487
|
+
If the attribute doesn't exist or is read-only
|
399
488
|
"""
|
489
|
+
if not hasattr(self._instance, name):
|
490
|
+
raise AttributeError(f"'{self.getClassName()}' object has no attribute '{name}'.")
|
491
|
+
delattr(self._instance, name)
|
492
|
+
|
493
|
+
def setMacro(self, name: str, value: Callable) -> None:
|
494
|
+
"""Set a callable attribute value.
|
495
|
+
|
496
|
+
Parameters
|
497
|
+
----------
|
498
|
+
name : str
|
499
|
+
The attribute name
|
500
|
+
value : Callable
|
501
|
+
The callable to set
|
502
|
+
|
503
|
+
Raises
|
504
|
+
------
|
505
|
+
AttributeError
|
506
|
+
If the value is not callable
|
507
|
+
"""
|
508
|
+
if not callable(value):
|
509
|
+
raise AttributeError(f"The value for '{name}' must be a callable.")
|
400
510
|
setattr(self._instance, name, value)
|
401
511
|
|
402
|
-
def
|
403
|
-
"""
|
512
|
+
def removeMacro(self, name: str) -> None:
|
513
|
+
"""Remove a callable attribute from the instance.
|
404
514
|
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
"""
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
callable
|
419
|
-
) if not name.startswith('__')
|
420
|
-
}
|
515
|
+
Parameters
|
516
|
+
----------
|
517
|
+
name : str
|
518
|
+
The attribute name to remove
|
519
|
+
|
520
|
+
Raises
|
521
|
+
------
|
522
|
+
AttributeError
|
523
|
+
If the attribute doesn't exist or is not callable
|
524
|
+
"""
|
525
|
+
if not hasattr(self._instance, name) or not callable(getattr(self._instance, name)):
|
526
|
+
raise AttributeError(f"'{self.getClassName()}' object has no callable macro '{name}'.")
|
527
|
+
delattr(self._instance, name)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
orionis/console.py,sha256=4gYWxf0fWYgJ4RKwARvnTPh06FL3GJ6SAZ7R2NzOICw,1342
|
3
|
-
orionis/framework.py,sha256=
|
3
|
+
orionis/framework.py,sha256=qijmmceXtP9OKeexD1p98DWoR1fkOIOLwMd6suDV0pM,1458
|
4
4
|
orionis/installer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
orionis/installer/manager.py,sha256=Li4TVziRXWfum02xNG4JHwbnLk-u8xzHjdqKz-D894k,2755
|
6
6
|
orionis/installer/output.py,sha256=7O9qa2xtXMB_4ZvVi-Klneom9YazwygAd_4uYAoxhbU,8548
|
@@ -173,7 +173,7 @@ orionis/luminate/support/inspection/reflection.py,sha256=xUILK5eEkTqXiAaOWVjEn_u
|
|
173
173
|
orionis/luminate/support/inspection/reflexion_abstract.py,sha256=nImlP07TpsT0azgIafGVZfSv1THrBoJOlNSSr9vDKiE,10848
|
174
174
|
orionis/luminate/support/inspection/reflexion_concrete.py,sha256=1ISuy2L6Oser-EhmpuGALmbauh7Z-X8Rx1YYgt5CabQ,7543
|
175
175
|
orionis/luminate/support/inspection/reflexion_concrete_with_abstract.py,sha256=z1cAscuG6a1E4ZJmwkp9HVQ0yhTAeFYKfnnyR_M-RFI,7480
|
176
|
-
orionis/luminate/support/inspection/reflexion_instance.py,sha256=
|
176
|
+
orionis/luminate/support/inspection/reflexion_instance.py,sha256=hf0c0PZkBcMXWvn4-Q2cPnTpVlQYUI-na9YgvHLpSzM,15554
|
177
177
|
orionis/luminate/support/inspection/reflexion_instance_with_abstract.py,sha256=PI_VSH8baxjPgheOYc9tQAlLq9mjxGm5zCOr-bLVksg,9406
|
178
178
|
orionis/luminate/support/inspection/reflexion_module.py,sha256=OgBXpqNJHkmq-gX4rqFStv-WVNe9R38RsgUgfHpak8k,405
|
179
179
|
orionis/luminate/support/inspection/reflexion_module_with_classname.py,sha256=YZHZI0XUZkSWnq9wrGxrIXtI64nY9yVSZoMe7PZXq8Y,620
|
@@ -231,13 +231,13 @@ tests/support/inspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
231
231
|
tests/support/inspection/test_reflection_abstract.py,sha256=6w8vm8H_fR4Z-KYjQGm8bq-HcetlpQl0EsDmDy3WzQ8,9311
|
232
232
|
tests/support/inspection/test_reflection_concrete.py,sha256=3BWSU7MkFEv2UgAVAwhiaMrzEwAyDBBJCa6edOENKSU,6782
|
233
233
|
tests/support/inspection/test_reflection_concrete_with_abstract.py,sha256=85cV9loDvtLG7sUxD6n_Ja0KV3x8FYakE2Z0W2Iruu8,4680
|
234
|
-
tests/support/inspection/test_reflection_instance.py,sha256=
|
234
|
+
tests/support/inspection/test_reflection_instance.py,sha256=JuTHhhsrO2yJQrSl1ITJ3NjAGg2mJbMSIyY4BvVcZbg,11141
|
235
235
|
tests/support/inspection/test_reflection_instance_with_abstract.py,sha256=l6tidHJUJpWhol-E5GfQEpMZ5gIVZFsegwVtMk8tYhs,4089
|
236
236
|
tests/support/inspection/fakes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
237
237
|
tests/support/inspection/fakes/fake_reflection_abstract.py,sha256=7qtz44brfFzE4oNYi9kIsvdWP79nP2FnzSz-0bU__pg,5045
|
238
238
|
tests/support/inspection/fakes/fake_reflection_concrete.py,sha256=j6gzsxE3xq5oJ30H_Hm1RsUwEY3jOYBu4sclxtD1ayo,1047
|
239
239
|
tests/support/inspection/fakes/fake_reflection_concrete_with_abstract.py,sha256=ibCjrtNM6BMf5Z5VMvat7E6zOAk5g9z--gj4ykKJWY8,2118
|
240
|
-
tests/support/inspection/fakes/fake_reflection_instance.py,sha256=
|
240
|
+
tests/support/inspection/fakes/fake_reflection_instance.py,sha256=NYfUF86nheHG_jVGmpwq3D22DyBZEmkJ-n08YkF5LqY,1336
|
241
241
|
tests/support/inspection/fakes/fake_reflection_instance_with_abstract.py,sha256=SfL8FuFmr650RlzXTrP4tGMfsPVZLhOxVnBXu_g1POg,1471
|
242
242
|
tests/support/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
243
243
|
tests/support/parsers/test_exception_parser.py,sha256=s-ZRbxyr9bs5uis2SM0IN-vCc-AJhWqRnEMIVgeEFXE,2363
|
@@ -249,9 +249,9 @@ tests/support/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
|
|
249
249
|
tests/support/patterns/test_singleton.py,sha256=U5uwpgGcP7-fIazsnFLwg30mmc24S62udhVIHuL-scY,634
|
250
250
|
tests/support/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
251
251
|
tests/support/standard/test_std.py,sha256=bJ5LV_OKEEZa_Bk3PTk9Kapk6qECLzcKf0hfR_x2QqM,2042
|
252
|
-
orionis-0.
|
253
|
-
orionis-0.
|
254
|
-
orionis-0.
|
255
|
-
orionis-0.
|
256
|
-
orionis-0.
|
257
|
-
orionis-0.
|
252
|
+
orionis-0.232.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
253
|
+
orionis-0.232.0.dist-info/METADATA,sha256=mcQWVf2OW3OHHuaU6yahxyd633xMoscMfKrUzOWGAUw,3003
|
254
|
+
orionis-0.232.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
255
|
+
orionis-0.232.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
|
256
|
+
orionis-0.232.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
257
|
+
orionis-0.232.0.dist-info/RECORD,,
|
@@ -1,16 +1,10 @@
|
|
1
|
+
import asyncio
|
2
|
+
|
1
3
|
class BaseFakeClass:
|
2
4
|
pass
|
3
5
|
|
4
6
|
class FakeClass(BaseFakeClass):
|
5
|
-
"""This is a test class for ReflexionInstance.
|
6
|
-
|
7
|
-
Attributes
|
8
|
-
----------
|
9
|
-
public_attr : int
|
10
|
-
An example public attribute
|
11
|
-
_private_attr : str
|
12
|
-
An example "private" attribute
|
13
|
-
"""
|
7
|
+
"""This is a test class for ReflexionInstance."""
|
14
8
|
|
15
9
|
class_attr: str = "class_value"
|
16
10
|
|
@@ -19,21 +13,8 @@ class FakeClass(BaseFakeClass):
|
|
19
13
|
self._private_attr = "secret"
|
20
14
|
self.dynamic_attr = None
|
21
15
|
|
22
|
-
def
|
23
|
-
"""Adds two numbers.
|
24
|
-
|
25
|
-
Parameters
|
26
|
-
----------
|
27
|
-
x : int
|
28
|
-
First number
|
29
|
-
y : int
|
30
|
-
Second number
|
31
|
-
|
32
|
-
Returns
|
33
|
-
-------
|
34
|
-
int
|
35
|
-
The sum of x and y
|
36
|
-
"""
|
16
|
+
def instanceMethod(self, x: int, y: int) -> int:
|
17
|
+
"""Adds two numbers."""
|
37
18
|
return x + y
|
38
19
|
|
39
20
|
@property
|
@@ -42,19 +23,29 @@ class FakeClass(BaseFakeClass):
|
|
42
23
|
return f"Value: {self.public_attr}"
|
43
24
|
|
44
25
|
@classmethod
|
45
|
-
def
|
26
|
+
def classMethod(cls) -> str:
|
46
27
|
"""A class method."""
|
47
28
|
return f"Class attr: {cls.class_attr}"
|
48
29
|
|
49
30
|
@staticmethod
|
50
|
-
def
|
31
|
+
def staticMethod(text: str) -> str:
|
51
32
|
"""A static method."""
|
52
33
|
return text.upper()
|
53
34
|
|
54
|
-
|
35
|
+
@staticmethod
|
36
|
+
async def staticAsyncMethod(text: str) -> str:
|
37
|
+
"""An asynchronous static method."""
|
38
|
+
await asyncio.sleep(0.1)
|
39
|
+
return text.upper()
|
40
|
+
|
41
|
+
def __privateMethod(self) -> str:
|
55
42
|
"""A 'private' method."""
|
56
43
|
return "This is private"
|
57
44
|
|
58
|
-
def
|
45
|
+
def _protectedMethod(self) -> str:
|
59
46
|
"""A 'protected' method."""
|
60
|
-
return "This is protected"
|
47
|
+
return "This is protected"
|
48
|
+
|
49
|
+
async def asyncMethod(self) -> str:
|
50
|
+
"""An async method."""
|
51
|
+
return "This is async"
|
@@ -45,14 +45,63 @@ class TestReflectionInstance(TestCase):
|
|
45
45
|
"""Ensure getMethods returns all methods of the class."""
|
46
46
|
reflex = Reflection.instance(FakeClass())
|
47
47
|
methods = reflex.getMethods()
|
48
|
-
self.assertTrue("
|
49
|
-
self.assertTrue("
|
48
|
+
self.assertTrue("__privateMethod" in methods)
|
49
|
+
self.assertTrue("_protectedMethod" in methods)
|
50
|
+
self.assertTrue("asyncMethod" in methods)
|
51
|
+
self.assertTrue("classMethod" in methods)
|
52
|
+
self.assertTrue("instanceMethod" in methods)
|
53
|
+
|
54
|
+
async def testReflectionInstanceGetProtectedMethods(self):
|
55
|
+
"""Check that getProtectedMethods returns all protected methods."""
|
56
|
+
reflex = Reflection.instance(FakeClass())
|
57
|
+
methods = reflex.getProtectedMethods()
|
58
|
+
self.assertTrue("_protectedMethod" in methods)
|
59
|
+
|
60
|
+
async def testReflectionInstanceGetPrivateMethods(self):
|
61
|
+
"""Ensure getPrivateMethods returns all private methods."""
|
62
|
+
reflex = Reflection.instance(FakeClass())
|
63
|
+
methods = reflex.getPrivateMethods()
|
64
|
+
self.assertTrue("__privateMethod" in methods)
|
65
|
+
|
66
|
+
async def testReflectionInstanceGetAsyncMethods(self):
|
67
|
+
"""Check that getAsyncMethods returns all async methods of the class."""
|
68
|
+
reflex = Reflection.instance(FakeClass())
|
69
|
+
methods = reflex.getAsyncMethods()
|
70
|
+
self.assertTrue("asyncMethod" in methods)
|
71
|
+
|
72
|
+
async def testReflectionInstanceGetSyncMethods(self):
|
73
|
+
"""Check that getASyncMethods returns all async methods of the class."""
|
74
|
+
reflex = Reflection.instance(FakeClass())
|
75
|
+
methods = reflex.getSyncMethods()
|
76
|
+
self.assertTrue("__privateMethod" in methods)
|
77
|
+
self.assertTrue("_protectedMethod" in methods)
|
78
|
+
self.assertTrue("classMethod" in methods)
|
79
|
+
self.assertTrue("instanceMethod" in methods)
|
80
|
+
|
81
|
+
async def testReflectionInstanceGetClassMethods(self):
|
82
|
+
"""Verify getClassMethods returns all class methods of the class."""
|
83
|
+
reflex = Reflection.instance(FakeClass())
|
84
|
+
methods = reflex.getClassMethods()
|
85
|
+
self.assertTrue("classMethod" in methods)
|
50
86
|
|
51
87
|
async def testReflectionInstanceGetStaticMethods(self):
|
52
88
|
"""Verify getStaticMethods returns all static methods of the class."""
|
53
89
|
reflex = Reflection.instance(FakeClass())
|
54
90
|
methods = reflex.getStaticMethods()
|
55
|
-
self.assertTrue("
|
91
|
+
self.assertTrue("staticAsyncMethod" in methods)
|
92
|
+
self.assertTrue("staticMethod" in methods)
|
93
|
+
|
94
|
+
async def testReflectionInstanceGetAsyncStaticMethods(self):
|
95
|
+
"""Ensure getSyncMethods returns all sync methods of the class."""
|
96
|
+
reflex = Reflection.instance(FakeClass())
|
97
|
+
methods = reflex.getAsyncStaticMethods()
|
98
|
+
self.assertTrue("staticAsyncMethod" in methods)
|
99
|
+
|
100
|
+
async def testReflectionInstanceGetSyncStaticMethods(self):
|
101
|
+
"""Check that getSyncMethods returns all sync methods of the class."""
|
102
|
+
reflex = Reflection.instance(FakeClass())
|
103
|
+
methods = reflex.getSyncStaticMethods()
|
104
|
+
self.assertTrue("staticMethod" in methods)
|
56
105
|
|
57
106
|
async def testReflectionInstanceGetPropertyNames(self):
|
58
107
|
"""Check that getPropertyNames returns all property names."""
|
@@ -60,17 +109,31 @@ class TestReflectionInstance(TestCase):
|
|
60
109
|
properties = reflex.getPropertyNames()
|
61
110
|
self.assertTrue("computed_property" in properties)
|
62
111
|
|
112
|
+
async def testReflectionInstanceGetProperty(self):
|
113
|
+
"""Ensure getProperty retrieves the correct property value."""
|
114
|
+
reflex = Reflection.instance(FakeClass())
|
115
|
+
property_value = reflex.getProperty("computed_property")
|
116
|
+
self.assertEqual(property_value, "Value: 42")
|
117
|
+
|
63
118
|
async def testReflectionInstanceCallMethod(self):
|
64
119
|
"""Ensure callMethod correctly invokes a method with arguments."""
|
65
120
|
reflex = Reflection.instance(FakeClass())
|
66
|
-
|
121
|
+
|
122
|
+
# Execute Sync Method
|
123
|
+
result = reflex.callMethod("instanceMethod", 1, 2)
|
67
124
|
self.assertEqual(result, 3)
|
68
125
|
|
126
|
+
# Execute Async Method
|
127
|
+
result = await reflex.callMethod("asyncMethod")
|
128
|
+
self.assertEqual(result, "This is async")
|
129
|
+
|
69
130
|
async def testReflectionInstanceGetMethodSignature(self):
|
70
131
|
"""Verify getMethodSignature returns the correct method signature."""
|
71
132
|
reflex = Reflection.instance(FakeClass())
|
72
|
-
signature = reflex.getMethodSignature("
|
133
|
+
signature = reflex.getMethodSignature("instanceMethod")
|
73
134
|
self.assertEqual(str(signature), "(x: int, y: int) -> int")
|
135
|
+
signature = reflex.getMethodSignature("__privateMethod")
|
136
|
+
self.assertEqual(str(signature), "() -> str")
|
74
137
|
|
75
138
|
async def testReflectionInstanceGetDocstring(self):
|
76
139
|
"""Check that getDocstring returns the correct class docstring."""
|
@@ -87,7 +150,8 @@ class TestReflectionInstance(TestCase):
|
|
87
150
|
async def testReflectionInstanceIsInstanceOf(self):
|
88
151
|
"""Verify isInstanceOf checks inheritance correctly."""
|
89
152
|
reflex = Reflection.instance(FakeClass())
|
90
|
-
|
153
|
+
result = reflex.isInstanceOf(BaseFakeClass)
|
154
|
+
self.assertTrue(result)
|
91
155
|
|
92
156
|
async def testReflectionInstanceGetSourceCode(self):
|
93
157
|
"""Check that getSourceCode returns the class source code."""
|
@@ -119,29 +183,50 @@ class TestReflectionInstance(TestCase):
|
|
119
183
|
attr_value = reflex.getAttribute("public_attr")
|
120
184
|
self.assertEqual(attr_value, 42)
|
121
185
|
|
122
|
-
async def testReflectionInstanceGetCallableMembers(self):
|
123
|
-
"""Verify getCallableMembers returns all callable members."""
|
124
|
-
reflex = Reflection.instance(FakeClass())
|
125
|
-
callable_members = reflex.getCallableMembers()
|
126
|
-
self.assertIn("instance_method", callable_members)
|
127
|
-
self.assertIn("class_method", callable_members)
|
128
|
-
self.assertIn("static_method", callable_members)
|
129
|
-
|
130
186
|
async def testReflectionInstanceSetAttribute(self):
|
131
187
|
"""Check that setAttribute correctly sets a new attribute."""
|
132
|
-
|
133
|
-
|
188
|
+
reflex = Reflection.instance(FakeClass())
|
189
|
+
reflex.setAttribute("new_attr", 'Orionis')
|
190
|
+
attr_value = reflex.getAttribute("new_attr")
|
191
|
+
self.assertEqual(attr_value, 'Orionis')
|
192
|
+
|
193
|
+
async def testReflectionInstanceRemoveAttribute(self):
|
194
|
+
"""Ensure removeAttribute correctly removes an attribute."""
|
195
|
+
reflex = Reflection.instance(FakeClass())
|
196
|
+
reflex.setAttribute("temp_attr", 'Temporary')
|
197
|
+
reflex.removeAttribute("temp_attr")
|
198
|
+
self.assertFalse(reflex.hasAttribute("temp_attr"))
|
199
|
+
|
200
|
+
async def testReflectionInstanceSetMacro(self):
|
201
|
+
"""Check that setMacro correctly."""
|
202
|
+
async def asyncMacro(cls: FakeClass, num):
|
134
203
|
await asyncio.sleep(0.1)
|
135
|
-
return cls.
|
204
|
+
return cls.instanceMethod(10, 12) + num
|
205
|
+
def syncMacro(cls: FakeClass, num):
|
206
|
+
return cls.instanceMethod(10, 12) + num
|
136
207
|
|
137
208
|
reflex = Reflection.instance(FakeClass())
|
138
|
-
reflex.setAttribute("myMacro", myMacro)
|
139
209
|
|
140
|
-
|
210
|
+
reflex.setMacro("asyncMacro", asyncMacro)
|
211
|
+
result = await reflex.callMethod("asyncMacro", reflex._instance, 3)
|
212
|
+
self.assertEqual(result, 25)
|
141
213
|
|
142
|
-
|
214
|
+
reflex.setMacro("syncMacro", syncMacro)
|
215
|
+
result = reflex.callMethod("syncMacro", reflex._instance, 3)
|
143
216
|
self.assertEqual(result, 25)
|
144
217
|
|
218
|
+
async def testReflectionInstanceRemoveMacro(self):
|
219
|
+
"""Ensure removeMacro correctly removes a macro."""
|
220
|
+
async def asyncMacro(cls: FakeClass, num):
|
221
|
+
await asyncio.sleep(0.1)
|
222
|
+
return cls.instanceMethod(10, 12) + num
|
223
|
+
|
224
|
+
reflex = Reflection.instance(FakeClass())
|
225
|
+
reflex.setMacro("asyncMacro", asyncMacro)
|
226
|
+
reflex.removeMacro("asyncMacro")
|
227
|
+
with self.assertRaises(Exception):
|
228
|
+
await reflex.callMethod("asyncMacro", reflex._instance, 3)
|
229
|
+
|
145
230
|
def testReflectionInstanceGetPropertySignature(self):
|
146
231
|
"""Ensure getPropertySignature returns the correct property signature."""
|
147
232
|
signature = Reflection.instance(FakeClass()).getPropertySignature('computed_property')
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|