orionis 0.231.0__py3-none-any.whl → 0.233.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 CHANGED
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.231.0"
8
+ VERSION = "0.233.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -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,13 +58,60 @@ class ReflexionInstance:
73
58
  -------
74
59
  Dict[str, Any]
75
60
  Dictionary of attribute names and their values
61
+ """
62
+ attributes : dict = vars(self._instance)
63
+ class_name : str = self.getClassName()
64
+ out_attributes = {}
65
+ for attr, value in attributes.items():
66
+ out_attributes[str(attr).replace(f"_{class_name}", "")] = value
67
+ return out_attributes
68
+
69
+ def getPublicAttributes(self) -> Dict[str, Any]:
70
+ """Get all public attributes of the instance.
71
+
72
+ Returns
73
+ -------
74
+ Dict[str, Any]
75
+ Dictionary of public attribute names and their values
76
+ """
77
+ attributes : dict = vars(self._instance)
78
+ out_attributes = {}
79
+ for attr, value in attributes.items():
80
+ if not str(attr).startswith("_"):
81
+ out_attributes[attr] = value
82
+ return out_attributes
83
+
84
+ def getPrivateAttributes(self) -> Dict[str, Any]:
85
+ """Get all private attributes of the instance.
86
+
87
+ Returns
88
+ -------
89
+ Dict[str, Any]
90
+ Dictionary of private attribute names and their values
91
+ """
92
+ attributes : dict = vars(self._instance)
93
+ class_name : str = self.getClassName()
94
+ out_attributes = {}
95
+ for attr, value in attributes.items():
96
+ if str(attr).startswith(f"_{class_name}"):
97
+ out_attributes[str(attr).replace(f"_{class_name}", "")] = value
98
+ return out_attributes
76
99
 
77
- Examples
78
- --------
79
- >>> reflex.getAttributes()
80
- {'attr1': value1, 'attr2': value2}
100
+ def getProtectedAttributes(self) -> Dict[str, Any]:
101
+ """Get all Protected attributes of the instance.
102
+
103
+ Returns
104
+ -------
105
+ Dict[str, Any]
106
+ Dictionary of Protected attribute names and their values
81
107
  """
82
- return vars(self._instance)
108
+ attributes : dict = vars(self._instance)
109
+ class_name : str = self.getClassName()
110
+ out_attributes = {}
111
+ for attr, value in attributes.items():
112
+ if str(attr).startswith("_") and not str(attr).startswith("__") and not str(attr).startswith(f"_{class_name}"):
113
+ out_attributes[attr] = value
114
+ return out_attributes
83
115
 
84
116
  def getMethods(self) -> List[str]:
85
117
  """Get all method names of the instance.
@@ -88,41 +120,165 @@ class ReflexionInstance:
88
120
  -------
89
121
  List[str]
90
122
  List of method names
123
+ """
124
+ class_name = self.getClassName()
125
+ methods = [name for name, _ in inspect.getmembers(
126
+ self._instance,
127
+ predicate=inspect.ismethod
128
+ )]
129
+
130
+ out_methods = []
131
+ for method in methods:
132
+ out_methods.append(method.replace(f"_{class_name}", ""))
91
133
 
92
- Examples
93
- --------
94
- >>> reflex.getMethods()
95
- ['method1', 'method2']
134
+ return out_methods
135
+
136
+ def getProtectedMethods(self) -> List[str]:
137
+ """Get all protected method names of the instance.
138
+
139
+ Returns
140
+ -------
141
+ List[str]
142
+ List of protected method names, excluding private methods (starting with '_')
96
143
  """
97
- return [name for name, _ in inspect.getmembers(
144
+ class_name = self.getClassName()
145
+ methods = [name for name, _ in inspect.getmembers(
98
146
  self._instance,
99
147
  predicate=inspect.ismethod
100
148
  )]
101
149
 
150
+ out_methods = []
151
+ for method in methods:
152
+ if method.startswith("_") and not method.startswith("__") and not method.startswith(f"_{class_name}"):
153
+ out_methods.append(method)
154
+
155
+ return out_methods
156
+
157
+ def getPrivateMethods(self) -> List[str]:
158
+ """Get all private method names of the instance.
159
+
160
+ Returns
161
+ -------
162
+ List[str]
163
+ List of private method names, excluding protected methods (starting with '_')
164
+ """
165
+ class_name = self.getClassName()
166
+ methods = [name for name, _ in inspect.getmembers(
167
+ self._instance,
168
+ predicate=inspect.ismethod
169
+ )]
170
+
171
+ out_methods = []
172
+ for method in methods:
173
+ if method.startswith(f"_{class_name}"):
174
+ out_methods.append(method.replace(f"_{class_name}", ""))
175
+
176
+ return out_methods
177
+
178
+ def getAsyncMethods(self) -> List[str]:
179
+ """
180
+ Get all asynchronous method names of the instance that are not static methods.
181
+
182
+ Returns
183
+ -------
184
+ List[str]
185
+ List of asynchronous method names
186
+ """
187
+ obj = self._instance
188
+ cls = obj if inspect.isclass(obj) else obj.__class__
189
+ class_name = self.getClassName()
190
+ methods = [
191
+ name for name, func in inspect.getmembers(obj, inspect.iscoroutinefunction)
192
+ if not isinstance(inspect.getattr_static(cls, name, None), staticmethod)
193
+ ]
194
+
195
+ out_methods = []
196
+ for method in methods:
197
+ out_methods.append(method.replace(f"_{class_name}", ""))
198
+
199
+ return out_methods
200
+
201
+ def getSyncMethods(self) -> List[str]:
202
+ """
203
+ Get all synchronous method names of the instance that are not static methods.
204
+
205
+ Returns
206
+ -------
207
+ List[str]
208
+ List of synchronous method names
209
+ """
210
+ obj = self._instance
211
+ cls = obj if inspect.isclass(obj) else obj.__class__
212
+ class_name = self.getClassName()
213
+ methods = [
214
+ name for name, func in inspect.getmembers(obj, predicate=inspect.ismethod)
215
+ if not inspect.iscoroutinefunction(func) and
216
+ not isinstance(inspect.getattr_static(cls, name, None), staticmethod)
217
+ ]
218
+
219
+ out_methods = []
220
+ for method in methods:
221
+ out_methods.append(method.replace(f"_{class_name}", ""))
222
+
223
+ return out_methods
224
+
225
+ def getClassMethods(self) -> List[str]:
226
+ """Get all class method names of the instance.
227
+
228
+ Returns
229
+ -------
230
+ List[str]
231
+ List of class method names.
232
+ """
233
+ return [
234
+ name for name in dir(self._instance.__class__)
235
+ if isinstance(inspect.getattr_static(self._instance.__class__, name), classmethod)
236
+ ]
237
+
102
238
  def getStaticMethods(self) -> List[str]:
103
239
  """Get all static method names of the instance.
104
240
 
105
241
  Returns
106
242
  -------
107
243
  List[str]
108
- List of static method names, excluding private methods (starting with '_')
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']
244
+ List of static method names.
121
245
  """
122
246
  return [
123
247
  name for name in dir(self._instance.__class__)
124
- if not name.startswith('_') and
125
- isinstance(inspect.getattr_static(self._instance.__class__, name), staticmethod)
248
+ if isinstance(inspect.getattr_static(self._instance.__class__, name), staticmethod)
249
+ ]
250
+
251
+ def getAsyncStaticMethods(self) -> List[str]:
252
+ """
253
+ Get all asynchronous method names of the instance that are not static methods.
254
+
255
+ Returns
256
+ -------
257
+ List[str]
258
+ List of asynchronous method names
259
+ """
260
+ obj = self._instance
261
+ cls = obj if inspect.isclass(obj) else obj.__class__
262
+ return [
263
+ name for name, func in inspect.getmembers(obj, inspect.iscoroutinefunction)
264
+ if isinstance(inspect.getattr_static(cls, name, None), staticmethod)
265
+ ]
266
+
267
+ def getSyncStaticMethods(self) -> List[str]:
268
+ """
269
+ Get all synchronous static method names of the instance.
270
+
271
+ Returns
272
+ -------
273
+ List[str]
274
+ List of synchronous static method names
275
+ """
276
+ obj = self._instance
277
+ cls = obj if inspect.isclass(obj) else obj.__class__
278
+ return [
279
+ name for name, func in inspect.getmembers(cls, inspect.isfunction)
280
+ if not inspect.iscoroutinefunction(func) and
281
+ isinstance(inspect.getattr_static(cls, name, None), staticmethod)
126
282
  ]
127
283
 
128
284
  def getPropertyNames(self) -> List[str]:
@@ -132,103 +288,117 @@ class ReflexionInstance:
132
288
  -------
133
289
  List[str]
134
290
  List of property names
135
-
136
- Examples
137
- --------
138
- >>> reflex.getPropertyNames()
139
- ['prop1', 'prop2']
140
291
  """
141
292
  return [name for name, _ in inspect.getmembers(
142
293
  self._instance.__class__,
143
294
  lambda x: isinstance(x, property)
144
295
  )]
145
296
 
146
- def callMethod(self, methodName: str, *args: Any, **kwargs: Any) -> Any:
147
- """Call a method on the instance.
297
+ def getProperty(self, propertyName: str) -> Any:
298
+ """Get the value of a property.
148
299
 
149
300
  Parameters
150
301
  ----------
151
- methodName : str
152
- Name of the method to call
153
- *args : Any
154
- Positional arguments for the method
155
- **kwargs : Any
156
- Keyword arguments for the method
302
+ propertyName : str
303
+ Name of the property
157
304
 
158
305
  Returns
159
306
  -------
160
307
  Any
161
- The return value of the method
308
+ The value of the property
162
309
 
163
310
  Raises
164
311
  ------
165
312
  AttributeError
166
- If the method doesn't exist
167
-
168
- Examples
169
- --------
170
- >>> reflex.callMethod('calculate', 2, 3)
171
- 5
313
+ If the property doesn't exist or is not a property
172
314
  """
173
- method = getattr(self._instance, methodName)
174
- return method(*args, **kwargs)
315
+ attr = getattr(self._instance.__class__, propertyName, None)
316
+ if isinstance(attr, property) and attr.fget is not None:
317
+ return getattr(self._instance, propertyName)
318
+ raise AttributeError(f"{propertyName} is not a property or doesn't have a getter.")
175
319
 
176
- def getMethodSignature(self, methodName: str) -> inspect.Signature:
177
- """Get the signature of a method.
320
+ def getPropertySignature(self, propertyName: str) -> inspect.Signature:
321
+ """Get the signature of a property.
178
322
 
179
323
  Parameters
180
324
  ----------
181
- methodName : str
182
- Name of the method
325
+ propertyName : str
326
+ Name of the property
183
327
 
184
328
  Returns
185
329
  -------
186
330
  inspect.Signature
187
- The method signature
331
+ The property signature
188
332
 
189
333
  Raises
190
334
  ------
191
335
  AttributeError
192
- If the method doesn't exist
193
-
194
- Examples
195
- --------
196
- >>> sig = reflex.getMethodSignature('calculate')
197
- >>> str(sig)
198
- '(x, y)'
336
+ If the property doesn't exist or is not a property
199
337
  """
200
- method = getattr(self._instance, methodName)
201
- if callable(method):
202
- return inspect.signature(method)
338
+ attr = getattr(self._instance.__class__, propertyName, None)
339
+ if isinstance(attr, property) and attr.fget is not None:
340
+ return inspect.signature(attr.fget)
341
+ raise AttributeError(f"{propertyName} is not a property or doesn't have a getter.")
203
342
 
204
- def getPropertySignature(self, propertyName: str) -> inspect.Signature:
205
- """Get the signature of a property getter.
343
+ def callMethod(self, methodName: str, *args: Any, **kwargs: Any) -> Any:
344
+ """Call a method on the instance.
206
345
 
207
346
  Parameters
208
347
  ----------
209
- propertyName : str
210
- Name of the property
348
+ methodName : str
349
+ Name of the method to call
350
+ *args : Any
351
+ Positional arguments for the method
352
+ **kwargs : Any
353
+ Keyword arguments for the method
211
354
 
212
355
  Returns
213
356
  -------
214
- inspect.Signature
215
- The property's getter method signature
357
+ Any
358
+ The result of the method call
216
359
 
217
360
  Raises
218
361
  ------
219
362
  AttributeError
220
- If the property doesn't exist or is not a property
363
+ If the method does not exist on the instance
364
+ TypeError
365
+ If the method is not callable
366
+ """
367
+
368
+ if methodName in self.getPrivateMethods():
369
+ methodName = f"_{self.getClassName()}{methodName}"
370
+
371
+ method = getattr(self._instance, methodName, None)
372
+
373
+ if method is None:
374
+ raise AttributeError(f"'{self.getClassName()}' object has no method '{methodName}'.")
375
+ if not callable(method):
376
+ raise TypeError(f"'{methodName}' is not callable on '{self.getClassName()}'.")
377
+
378
+ if inspect.iscoroutinefunction(method):
379
+ return AsyncIO.run(method(*args, **kwargs))
380
+
381
+ return method(*args, **kwargs)
382
+
383
+ def getMethodSignature(self, methodName: str) -> inspect.Signature:
384
+ """Get the signature of a method.
385
+
386
+ Parameters
387
+ ----------
388
+ methodName : str
389
+ Name of the method
221
390
 
222
- Examples
223
- --------
224
- >>> sig = reflex.getPropertySignature('config')
225
- >>> str(sig)
226
- '(self)'
391
+ Returns
392
+ -------
393
+ inspect.Signature
394
+ The method signature
227
395
  """
228
- attr = getattr(type(self._instance), propertyName, None)
229
- if isinstance(attr, property) and attr.fget is not None:
230
- return inspect.signature(attr.fget)
231
- raise AttributeError(f"{propertyName} is not a property or doesn't have a getter.")
396
+ if methodName in self.getPrivateMethods():
397
+ methodName = f"_{self.getClassName()}{methodName}"
398
+
399
+ method = getattr(self._instance, methodName)
400
+ if callable(method):
401
+ return inspect.signature(method)
232
402
 
233
403
  def getDocstring(self) -> Optional[str]:
234
404
  """Get the docstring of the instance's class.
@@ -237,11 +407,6 @@ class ReflexionInstance:
237
407
  -------
238
408
  Optional[str]
239
409
  The class docstring, or None if not available
240
-
241
- Examples
242
- --------
243
- >>> reflex.getDocstring()
244
- 'This class does something important.'
245
410
  """
246
411
  return self._instance.__class__.__doc__
247
412
 
@@ -252,11 +417,6 @@ class ReflexionInstance:
252
417
  -------
253
418
  Tuple[Type, ...]
254
419
  Tuple of base classes
255
-
256
- Examples
257
- --------
258
- >>> reflex.getBaseClasses()
259
- (<class 'object'>,)
260
420
  """
261
421
  return self._instance.__class__.__bases__
262
422
 
@@ -272,11 +432,6 @@ class ReflexionInstance:
272
432
  -------
273
433
  bool
274
434
  True if the instance is of the specified class
275
-
276
- Examples
277
- --------
278
- >>> reflex.isInstanceOf(SomeClass)
279
- True
280
435
  """
281
436
  return isinstance(self._instance, cls)
282
437
 
@@ -287,13 +442,6 @@ class ReflexionInstance:
287
442
  -------
288
443
  Optional[str]
289
444
  The source code if available, None otherwise
290
-
291
- Examples
292
- --------
293
- >>> print(reflex.getSourceCode())
294
- class SomeClass:
295
- def __init__(self):
296
- ...
297
445
  """
298
446
  try:
299
447
  return inspect.getsource(self._instance.__class__)
@@ -307,11 +455,6 @@ class ReflexionInstance:
307
455
  -------
308
456
  Optional[str]
309
457
  The file path if available, None otherwise
310
-
311
- Examples
312
- --------
313
- >>> reflex.getFileLocation()
314
- '/path/to/module.py'
315
458
  """
316
459
  try:
317
460
  return inspect.getfile(self._instance.__class__)
@@ -325,11 +468,6 @@ class ReflexionInstance:
325
468
  -------
326
469
  Dict[str, Any]
327
470
  Dictionary of attribute names and their type annotations
328
-
329
- Examples
330
- --------
331
- >>> reflex.getAnnotations()
332
- {'name': str, 'value': int}
333
471
  """
334
472
  return self._instance.__class__.__annotations__
335
473
 
@@ -345,11 +483,6 @@ class ReflexionInstance:
345
483
  -------
346
484
  bool
347
485
  True if the attribute exists
348
-
349
- Examples
350
- --------
351
- >>> reflex.hasAttribute('important_attr')
352
- True
353
486
  """
354
487
  return hasattr(self._instance, name)
355
488
 
@@ -370,13 +503,9 @@ class ReflexionInstance:
370
503
  ------
371
504
  AttributeError
372
505
  If the attribute doesn't exist
373
-
374
- Examples
375
- --------
376
- >>> reflex.getAttribute('count')
377
- 42
378
506
  """
379
- return getattr(self._instance, name)
507
+ attrs = self.getAttributes()
508
+ return attrs.get(name, getattr(self._instance, name, None))
380
509
 
381
510
  def setAttribute(self, name: str, value: Any) -> None:
382
511
  """Set an attribute value.
@@ -392,29 +521,60 @@ class ReflexionInstance:
392
521
  ------
393
522
  AttributeError
394
523
  If the attribute is read-only
524
+ """
525
+ if callable(value):
526
+ raise AttributeError(f"Cannot set attribute '{name}' to a callable.")
527
+ setattr(self._instance, name, value)
528
+
529
+ def removeAttribute(self, name: str) -> None:
530
+ """Remove an attribute from the instance.
395
531
 
396
- Examples
397
- --------
398
- >>> reflex.setAttribute('count', 100)
532
+ Parameters
533
+ ----------
534
+ name : str
535
+ The attribute name to remove
536
+
537
+ Raises
538
+ ------
539
+ AttributeError
540
+ If the attribute doesn't exist or is read-only
399
541
  """
542
+ if not hasattr(self._instance, name):
543
+ raise AttributeError(f"'{self.getClassName()}' object has no attribute '{name}'.")
544
+ delattr(self._instance, name)
545
+
546
+ def setMacro(self, name: str, value: Callable) -> None:
547
+ """Set a callable attribute value.
548
+
549
+ Parameters
550
+ ----------
551
+ name : str
552
+ The attribute name
553
+ value : Callable
554
+ The callable to set
555
+
556
+ Raises
557
+ ------
558
+ AttributeError
559
+ If the value is not callable
560
+ """
561
+ if not callable(value):
562
+ raise AttributeError(f"The value for '{name}' must be a callable.")
400
563
  setattr(self._instance, name, value)
401
564
 
402
- def getCallableMembers(self) -> Dict[str, Callable]:
403
- """Get all callable members (methods) of the instance.
565
+ def removeMacro(self, name: str) -> None:
566
+ """Remove a callable attribute from the instance.
404
567
 
405
- Returns
406
- -------
407
- Dict[str, Callable]
408
- Dictionary of method names and their callable objects
409
-
410
- Examples
411
- --------
412
- >>> reflex.getCallableMembers()
413
- {'calculate': <bound method SomeClass.calculate>, ...}
414
- """
415
- return {
416
- name: member for name, member in inspect.getmembers(
417
- self._instance,
418
- callable
419
- ) if not name.startswith('__')
420
- }
568
+ Parameters
569
+ ----------
570
+ name : str
571
+ The attribute name to remove
572
+
573
+ Raises
574
+ ------
575
+ AttributeError
576
+ If the attribute doesn't exist or is not callable
577
+ """
578
+ if not hasattr(self._instance, name) or not callable(getattr(self._instance, name)):
579
+ raise AttributeError(f"'{self.getClassName()}' object has no callable macro '{name}'.")
580
+ delattr(self._instance, name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.231.0
3
+ Version: 0.233.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -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=N03ehWIO3Lpa18h6NyDaoi8pIFeyLEn9PPlGQObIxxU,1458
3
+ orionis/framework.py,sha256=zMVqUWppG3gKA3WkFIStp5LPdnRnvB_1vZjloIBbWv8,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=LNAgw4sZvHT7UMiObHTGk7xgqpIeKYHAQRgRpuPfEas,10842
176
+ orionis/luminate/support/inspection/reflexion_instance.py,sha256=GFtJMehIZq58jVJ8SOofQuwgk4IgWGV-g2PPGkKb24o,17598
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=8XKkEhboESLG2UaJ-STJ8STe7mUO4YDkKy01kiiGvkI,7197
234
+ tests/support/inspection/test_reflection_instance.py,sha256=fapzzH2Qyacsy-S1I2Uq9k3B6fZ3Qbb3IJxvx451zoU,12668
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=G16rZdJWC3L8SGEQkmwktvw4n7IAusIIx9Tm-ZFLcg4,1419
240
+ tests/support/inspection/fakes/fake_reflection_instance.py,sha256=P5lSFiGPLLAPOIRmw4VE3YWctxlqmXARRiWMSGLrg3E,1382
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.231.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
253
- orionis-0.231.0.dist-info/METADATA,sha256=2pqpyP5KUXDaYxwy7LDaeiXSoiLgz63YsUh3SujLclk,3003
254
- orionis-0.231.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
255
- orionis-0.231.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
256
- orionis-0.231.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
257
- orionis-0.231.0.dist-info/RECORD,,
252
+ orionis-0.233.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
253
+ orionis-0.233.0.dist-info/METADATA,sha256=gp1CXdBLUnA91O29GEY1b6JD8w-kUcrK4y6nQdfTZHw,3003
254
+ orionis-0.233.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
255
+ orionis-0.233.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
256
+ orionis-0.233.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
257
+ orionis-0.233.0.dist-info/RECORD,,
@@ -1,39 +1,21 @@
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
 
17
11
  def __init__(self) -> None:
18
12
  self.public_attr = 42
19
- self._private_attr = "secret"
13
+ self._protected_attr = "protected"
14
+ self.__private_attr = "private"
20
15
  self.dynamic_attr = None
21
16
 
22
- def instance_method(self, x: int, y: int) -> int:
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
- """
17
+ def instanceMethod(self, x: int, y: int) -> int:
18
+ """Adds two numbers."""
37
19
  return x + y
38
20
 
39
21
  @property
@@ -42,19 +24,29 @@ class FakeClass(BaseFakeClass):
42
24
  return f"Value: {self.public_attr}"
43
25
 
44
26
  @classmethod
45
- def class_method(cls) -> str:
27
+ def classMethod(cls) -> str:
46
28
  """A class method."""
47
29
  return f"Class attr: {cls.class_attr}"
48
30
 
49
31
  @staticmethod
50
- def static_method(text: str) -> str:
32
+ def staticMethod(text: str) -> str:
51
33
  """A static method."""
52
34
  return text.upper()
53
35
 
54
- def __private_method(self) -> str:
36
+ @staticmethod
37
+ async def staticAsyncMethod(text: str) -> str:
38
+ """An asynchronous static method."""
39
+ await asyncio.sleep(0.1)
40
+ return text.upper()
41
+
42
+ def __privateMethod(self) -> str:
55
43
  """A 'private' method."""
56
44
  return "This is private"
57
45
 
58
- def _protected_method(self) -> str:
46
+ def _protectedMethod(self) -> str:
59
47
  """A 'protected' method."""
60
- return "This is protected"
48
+ return "This is protected"
49
+
50
+ async def asyncMethod(self) -> str:
51
+ """An async method."""
52
+ return "This is async"
@@ -38,21 +38,89 @@ class TestReflectionInstance(TestCase):
38
38
  reflex = Reflection.instance(FakeClass())
39
39
  attributes = reflex.getAttributes()
40
40
  self.assertTrue("public_attr" in attributes)
41
- self.assertTrue("_private_attr" in attributes)
41
+ self.assertTrue("__private_attr" in attributes)
42
42
  self.assertTrue("dynamic_attr" in attributes)
43
43
 
44
+ async def testReflectionInstanceGetPublicAttributes(self):
45
+ """Ensure getPublicAttributes returns all public attributes."""
46
+ reflex = Reflection.instance(FakeClass())
47
+ attributes = reflex.getPublicAttributes()
48
+ self.assertTrue("public_attr" in attributes)
49
+ self.assertTrue("dynamic_attr" in attributes)
50
+
51
+ async def testReflectionInstanceGetProtectedAttributes(self):
52
+ """Check that getProtectedAttributes returns all protected attributes."""
53
+ reflex = Reflection.instance(FakeClass())
54
+ attributes = reflex.getProtectedAttributes()
55
+ self.assertTrue("_protected_attr" in attributes)
56
+
57
+ async def testReflectionInstanceGetPrivateAttributes(self):
58
+ """Ensure getPrivateAttributes returns all private attributes."""
59
+ reflex = Reflection.instance(FakeClass())
60
+ attributes = reflex.getPrivateAttributes()
61
+ self.assertTrue("__private_attr" in attributes)
62
+
44
63
  async def testReflectionInstanceGetMethods(self):
45
64
  """Ensure getMethods returns all methods of the class."""
46
65
  reflex = Reflection.instance(FakeClass())
47
66
  methods = reflex.getMethods()
48
- self.assertTrue("instance_method" in methods)
49
- self.assertTrue("class_method" in methods)
67
+ self.assertTrue("__privateMethod" in methods)
68
+ self.assertTrue("_protectedMethod" in methods)
69
+ self.assertTrue("asyncMethod" in methods)
70
+ self.assertTrue("classMethod" in methods)
71
+ self.assertTrue("instanceMethod" in methods)
72
+
73
+ async def testReflectionInstanceGetProtectedMethods(self):
74
+ """Check that getProtectedMethods returns all protected methods."""
75
+ reflex = Reflection.instance(FakeClass())
76
+ methods = reflex.getProtectedMethods()
77
+ self.assertTrue("_protectedMethod" in methods)
78
+
79
+ async def testReflectionInstanceGetPrivateMethods(self):
80
+ """Ensure getPrivateMethods returns all private methods."""
81
+ reflex = Reflection.instance(FakeClass())
82
+ methods = reflex.getPrivateMethods()
83
+ self.assertTrue("__privateMethod" in methods)
84
+
85
+ async def testReflectionInstanceGetAsyncMethods(self):
86
+ """Check that getAsyncMethods returns all async methods of the class."""
87
+ reflex = Reflection.instance(FakeClass())
88
+ methods = reflex.getAsyncMethods()
89
+ self.assertTrue("asyncMethod" in methods)
90
+
91
+ async def testReflectionInstanceGetSyncMethods(self):
92
+ """Check that getASyncMethods returns all async methods of the class."""
93
+ reflex = Reflection.instance(FakeClass())
94
+ methods = reflex.getSyncMethods()
95
+ self.assertTrue("__privateMethod" in methods)
96
+ self.assertTrue("_protectedMethod" in methods)
97
+ self.assertTrue("classMethod" in methods)
98
+ self.assertTrue("instanceMethod" in methods)
99
+
100
+ async def testReflectionInstanceGetClassMethods(self):
101
+ """Verify getClassMethods returns all class methods of the class."""
102
+ reflex = Reflection.instance(FakeClass())
103
+ methods = reflex.getClassMethods()
104
+ self.assertTrue("classMethod" in methods)
50
105
 
51
106
  async def testReflectionInstanceGetStaticMethods(self):
52
107
  """Verify getStaticMethods returns all static methods of the class."""
53
108
  reflex = Reflection.instance(FakeClass())
54
109
  methods = reflex.getStaticMethods()
55
- self.assertTrue("static_method" in methods)
110
+ self.assertTrue("staticAsyncMethod" in methods)
111
+ self.assertTrue("staticMethod" in methods)
112
+
113
+ async def testReflectionInstanceGetAsyncStaticMethods(self):
114
+ """Ensure getSyncMethods returns all sync methods of the class."""
115
+ reflex = Reflection.instance(FakeClass())
116
+ methods = reflex.getAsyncStaticMethods()
117
+ self.assertTrue("staticAsyncMethod" in methods)
118
+
119
+ async def testReflectionInstanceGetSyncStaticMethods(self):
120
+ """Check that getSyncMethods returns all sync methods of the class."""
121
+ reflex = Reflection.instance(FakeClass())
122
+ methods = reflex.getSyncStaticMethods()
123
+ self.assertTrue("staticMethod" in methods)
56
124
 
57
125
  async def testReflectionInstanceGetPropertyNames(self):
58
126
  """Check that getPropertyNames returns all property names."""
@@ -60,17 +128,31 @@ class TestReflectionInstance(TestCase):
60
128
  properties = reflex.getPropertyNames()
61
129
  self.assertTrue("computed_property" in properties)
62
130
 
131
+ async def testReflectionInstanceGetProperty(self):
132
+ """Ensure getProperty retrieves the correct property value."""
133
+ reflex = Reflection.instance(FakeClass())
134
+ property_value = reflex.getProperty("computed_property")
135
+ self.assertEqual(property_value, "Value: 42")
136
+
63
137
  async def testReflectionInstanceCallMethod(self):
64
138
  """Ensure callMethod correctly invokes a method with arguments."""
65
139
  reflex = Reflection.instance(FakeClass())
66
- result = reflex.callMethod("instance_method", 1, 2)
140
+
141
+ # Execute Sync Method
142
+ result = reflex.callMethod("instanceMethod", 1, 2)
67
143
  self.assertEqual(result, 3)
68
144
 
145
+ # Execute Async Method
146
+ result = await reflex.callMethod("asyncMethod")
147
+ self.assertEqual(result, "This is async")
148
+
69
149
  async def testReflectionInstanceGetMethodSignature(self):
70
150
  """Verify getMethodSignature returns the correct method signature."""
71
151
  reflex = Reflection.instance(FakeClass())
72
- signature = reflex.getMethodSignature("instance_method")
152
+ signature = reflex.getMethodSignature("instanceMethod")
73
153
  self.assertEqual(str(signature), "(x: int, y: int) -> int")
154
+ signature = reflex.getMethodSignature("__privateMethod")
155
+ self.assertEqual(str(signature), "() -> str")
74
156
 
75
157
  async def testReflectionInstanceGetDocstring(self):
76
158
  """Check that getDocstring returns the correct class docstring."""
@@ -87,7 +169,8 @@ class TestReflectionInstance(TestCase):
87
169
  async def testReflectionInstanceIsInstanceOf(self):
88
170
  """Verify isInstanceOf checks inheritance correctly."""
89
171
  reflex = Reflection.instance(FakeClass())
90
- self.assertTrue(reflex.isInstanceOf(BaseFakeClass))
172
+ result = reflex.isInstanceOf(BaseFakeClass)
173
+ self.assertTrue(result)
91
174
 
92
175
  async def testReflectionInstanceGetSourceCode(self):
93
176
  """Check that getSourceCode returns the class source code."""
@@ -118,30 +201,62 @@ class TestReflectionInstance(TestCase):
118
201
  reflex = Reflection.instance(FakeClass())
119
202
  attr_value = reflex.getAttribute("public_attr")
120
203
  self.assertEqual(attr_value, 42)
121
-
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)
204
+ attr_value = reflex.getAttribute("__private_attr")
205
+ self.assertEqual(attr_value, "private")
129
206
 
130
207
  async def testReflectionInstanceSetAttribute(self):
131
208
  """Check that setAttribute correctly sets a new attribute."""
132
- async def myMacro(cls: FakeClass, num):
133
- """Simulate an async function with an async sleep."""
209
+ reflex = Reflection.instance(FakeClass())
210
+ reflex.setAttribute("new_attr", 'Orionis')
211
+ attr_value = reflex.getAttribute("new_attr")
212
+ self.assertEqual(attr_value, 'Orionis')
213
+ reflex.setAttribute("__new_private_attr", 'Hidden')
214
+ attr_value = reflex.getAttribute("__new_private_attr")
215
+ self.assertEqual(attr_value, 'Hidden')
216
+
217
+ async def testReflectionInstanceRemoveAttribute(self):
218
+ """Ensure removeAttribute correctly removes an attribute."""
219
+ reflex = Reflection.instance(FakeClass())
220
+ reflex.setAttribute("temp_attr", 'Temporary')
221
+ reflex.removeAttribute("temp_attr")
222
+ self.assertFalse(reflex.hasAttribute("temp_attr"))
223
+
224
+ async def testReflectionInstanceSetMacro(self):
225
+ """Check that setMacro correctly."""
226
+ async def asyncMacro(cls: FakeClass, num):
134
227
  await asyncio.sleep(0.1)
135
- return cls.instance_method(10, 12) + num
228
+ return cls.instanceMethod(10, 12) + num
229
+ def syncMacro(cls: FakeClass, num):
230
+ return cls.instanceMethod(10, 12) + num
231
+ def __privateMacro(cls: FakeClass, num):
232
+ return cls.instanceMethod(10, 12) + num
136
233
 
137
234
  reflex = Reflection.instance(FakeClass())
138
- reflex.setAttribute("myMacro", myMacro)
139
235
 
140
- self.assertTrue(reflex.hasAttribute("myMacro"))
236
+ reflex.setMacro("asyncMacro", asyncMacro)
237
+ result = await reflex.callMethod("asyncMacro", reflex._instance, 3)
238
+ self.assertEqual(result, 25)
239
+
240
+ reflex.setMacro("syncMacro", syncMacro)
241
+ result = reflex.callMethod("syncMacro", reflex._instance, 3)
242
+ self.assertEqual(result, 25)
141
243
 
142
- result = await reflex.callMethod("myMacro", reflex._instance, 3)
244
+ reflex.setMacro("__privateMacro", __privateMacro)
245
+ result = reflex.callMethod("__privateMacro", reflex._instance, 3)
143
246
  self.assertEqual(result, 25)
144
247
 
248
+ async def testReflectionInstanceRemoveMacro(self):
249
+ """Ensure removeMacro correctly removes a macro."""
250
+ async def asyncMacro(cls: FakeClass, num):
251
+ await asyncio.sleep(0.1)
252
+ return cls.instanceMethod(10, 12) + num
253
+
254
+ reflex = Reflection.instance(FakeClass())
255
+ reflex.setMacro("asyncMacro", asyncMacro)
256
+ reflex.removeMacro("asyncMacro")
257
+ with self.assertRaises(Exception):
258
+ await reflex.callMethod("asyncMacro", reflex._instance, 3)
259
+
145
260
  def testReflectionInstanceGetPropertySignature(self):
146
261
  """Ensure getPropertySignature returns the correct property signature."""
147
262
  signature = Reflection.instance(FakeClass()).getPropertySignature('computed_property')