orionis 0.611.0__py3-none-any.whl → 0.612.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.
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.611.0"
8
+ VERSION = "0.612.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -245,24 +245,56 @@ class ReflectionConcrete(IReflectionConcrete):
245
245
  """
246
246
  return self._concrete.__bases__
247
247
 
248
- def getSourceCode(self) -> str:
248
+ def getSourceCode(self, method: str = None) -> str | None:
249
249
  """
250
- Get the source code of the reflected class.
250
+ Retrieve the source code for the reflected class or a specific method.
251
+
252
+ Parameters
253
+ ----------
254
+ method : str, optional
255
+ The name of the method whose source code should be retrieved. If not provided,
256
+ the source code of the entire class is returned. If the method name refers to a
257
+ private method, Python name mangling is handled automatically.
251
258
 
252
259
  Returns
253
260
  -------
254
- str
255
- The complete source code of the class definition.
261
+ str or None
262
+ The source code as a string if available. Returns None if the source code cannot
263
+ be found (e.g., for built-in or dynamically generated classes/methods), or if the
264
+ specified method does not exist.
256
265
 
257
- Raises
258
- ------
259
- ReflectionValueError
260
- If the source code cannot be retrieved (e.g., built-in classes).
266
+ Notes
267
+ -----
268
+ - If `method` is specified and refers to a private method, name mangling is handled automatically.
269
+ - If the source code cannot be found (e.g., for built-in or dynamically generated classes/methods), None is returned.
270
+ - If the specified method does not exist in the class, None is returned.
261
271
  """
272
+
262
273
  try:
263
- return inspect.getsource(self._concrete)
264
- except OSError as e:
265
- raise ReflectionValueError(f"Could not retrieve source code for '{self._concrete.__name__}': {e}")
274
+
275
+ # Return the source code of the entire class
276
+ if not method:
277
+ return inspect.getsource(self._concrete)
278
+
279
+ # Handle private method name mangling for methods starting with double underscore
280
+ else:
281
+
282
+ # Handle private method name mangling
283
+ if method.startswith("__") and not method.endswith("__"):
284
+ class_name = self.getClassName()
285
+ method = f"_{class_name}{method}"
286
+
287
+ # Check if the method exists in the class
288
+ if not self.hasMethod(method):
289
+ return None
290
+
291
+ # Return the source code of the specified method
292
+ return inspect.getsource(getattr(self._concrete, method))
293
+
294
+ except (TypeError, OSError):
295
+
296
+ # Return None if the source code cannot be retrieved (e.g., built-in or dynamic)
297
+ return None
266
298
 
267
299
  def getFile(self) -> str:
268
300
  """
@@ -438,25 +470,36 @@ class ReflectionConcrete(IReflectionConcrete):
438
470
 
439
471
  def getAttributes(self) -> dict:
440
472
  """
441
- Get all class attributes regardless of visibility.
473
+ Retrieve all class attributes across all visibility levels.
442
474
 
443
- Combines public, protected, private, and dunder attributes into a
444
- single dictionary for comprehensive attribute access.
475
+ This method aggregates and returns a dictionary containing all attributes
476
+ defined on the reflected class, including public, protected, private (with
477
+ name mangling resolved), and dunder (magic) attributes. Callable members,
478
+ static methods, class methods, and properties are excluded from the result.
445
479
 
446
480
  Returns
447
481
  -------
448
482
  dict
449
- A dictionary mapping attribute names to their values, including
450
- all visibility levels (public, protected, private, dunder).
483
+ A dictionary mapping attribute names (as strings) to their corresponding
484
+ values. The dictionary includes attributes of all visibility levels:
485
+ public, protected, private (with name mangling removed), and dunder
486
+ attributes, but excludes methods and properties. The result is cached
487
+ after the first call for performance.
451
488
  """
452
489
 
453
- # Combine all attribute types into a single dictionary
454
- return {
455
- **self.getPublicAttributes(),
456
- **self.getProtectedAttributes(),
457
- **self.getPrivateAttributes(),
458
- **self.getDunderAttributes()
459
- }
490
+ # Use cache to avoid recomputation on subsequent calls
491
+ if not hasattr(self, "_ReflectionConcrete__cacheGetAttributes"):
492
+
493
+ # Merge all attribute dictionaries from different visibility levels
494
+ self.__cacheGetAttributes = {
495
+ **self.getPublicAttributes(),
496
+ **self.getProtectedAttributes(),
497
+ **self.getPrivateAttributes(),
498
+ **self.getDunderAttributes()
499
+ }
500
+
501
+ # Return the cached dictionary of all attributes
502
+ return self.__cacheGetAttributes
460
503
 
461
504
  def getPublicAttributes(self) -> dict:
462
505
  """
@@ -769,27 +812,36 @@ class ReflectionConcrete(IReflectionConcrete):
769
812
 
770
813
  def getMethods(self) -> List[str]:
771
814
  """
772
- Get all method names from the reflected class.
815
+ Retrieve all method names defined in the reflected class, including instance, class, and static methods.
773
816
 
774
- Combines all types of methods including instance methods, class methods,
775
- and static methods with different visibility levels.
817
+ This method aggregates method names from all visibility levels (public, protected, private) and method types
818
+ (instance, class, static). The result is cached after the first call to improve performance on subsequent calls.
776
819
 
777
820
  Returns
778
821
  -------
779
822
  List[str]
780
- A comprehensive list of all method names in the class.
781
- """
782
- return [
783
- *self.getPublicMethods(),
784
- *self.getProtectedMethods(),
785
- *self.getPrivateMethods(),
786
- *self.getPublicClassMethods(),
787
- *self.getProtectedClassMethods(),
788
- *self.getPrivateClassMethods(),
789
- *self.getPublicStaticMethods(),
790
- *self.getProtectedStaticMethods(),
791
- *self.getPrivateStaticMethods(),
792
- ]
823
+ A list containing the names of all methods (instance, class, and static) defined in the class,
824
+ including public, protected, and private methods. The list is cached for efficiency.
825
+ """
826
+
827
+ # Check if the method names have already been cached
828
+ if not hasattr(self, "_ReflectionConcrete__cacheGetMethods"):
829
+
830
+ # Aggregate all method names from different categories and cache the result
831
+ self.__cacheGetMethods = [
832
+ *self.getPublicMethods(),
833
+ *self.getProtectedMethods(),
834
+ *self.getPrivateMethods(),
835
+ *self.getPublicClassMethods(),
836
+ *self.getProtectedClassMethods(),
837
+ *self.getPrivateClassMethods(),
838
+ *self.getPublicStaticMethods(),
839
+ *self.getProtectedStaticMethods(),
840
+ *self.getPrivateStaticMethods(),
841
+ ]
842
+
843
+ # Return the cached list of method names
844
+ return self.__cacheGetMethods
793
845
 
794
846
  def getPublicMethods(self) -> list:
795
847
  """
@@ -189,18 +189,52 @@ class ReflectionInstance(IReflectionInstance):
189
189
  """
190
190
  return self._instance.__class__.__bases__
191
191
 
192
- def getSourceCode(self) -> Optional[str]:
192
+ def getSourceCode(self, method: str = None) -> Optional[str]:
193
193
  """
194
- Get the source code of the instance's class.
194
+ Retrieve the source code of the instance's class or a specific method.
195
+
196
+ Parameters
197
+ ----------
198
+ method : str, optional
199
+ The name of the method whose source code should be retrieved. If not provided,
200
+ the source code of the entire class is returned.
195
201
 
196
202
  Returns
197
203
  -------
198
204
  Optional[str]
199
- The source code if available, None otherwise
205
+ The source code as a string if available; otherwise, None.
206
+
207
+ Raises
208
+ ------
209
+ None
210
+ This method does not raise exceptions; it returns None if the source code cannot be retrieved.
211
+
212
+ Notes
213
+ -----
214
+ - If `method` is specified and refers to a private method, name mangling is handled automatically.
215
+ - If the source code cannot be found (e.g., for built-in or dynamically generated classes/methods), None is returned.
200
216
  """
201
217
  try:
202
- return inspect.getsource(self._instance.__class__)
218
+ if not method:
219
+ # Return the source code of the class
220
+ return inspect.getsource(self._instance.__class__)
221
+ else:
222
+
223
+ # Handle private method name mangling
224
+ if method.startswith("__") and not method.endswith("__"):
225
+ class_name = self.getClassName()
226
+ method = f"_{class_name}{method}"
227
+
228
+ # Check if the method exists
229
+ if not self.hasMethod(method):
230
+ return None
231
+
232
+ # Return the source code of the specified method
233
+ return inspect.getsource(getattr(self._instance.__class__, method))
234
+
203
235
  except (TypeError, OSError):
236
+
237
+ # Return None if the source code cannot be retrieved
204
238
  return None
205
239
 
206
240
  def getFile(self) -> Optional[str]:
@@ -340,19 +374,38 @@ class ReflectionInstance(IReflectionInstance):
340
374
 
341
375
  def getAttributes(self) -> Dict[str, Any]:
342
376
  """
343
- Get all attributes of the instance, including public, private, protected, and dunder attributes.
377
+ Retrieve all attributes of the instance, including public, protected, private, and dunder (magic) attributes.
378
+
379
+ This method aggregates attributes from all visibility levels by combining the results of
380
+ `getPublicAttributes`, `getProtectedAttributes`, `getPrivateAttributes`, and `getDunderAttributes`.
381
+ The result is cached for subsequent calls to improve performance.
344
382
 
345
383
  Returns
346
384
  -------
347
385
  Dict[str, Any]
348
- Dictionary of all attribute names and their values
386
+ A dictionary mapping attribute names (as strings) to their corresponding values for all
387
+ attributes of the instance, including public, protected, private, and dunder attributes.
388
+
389
+ Notes
390
+ -----
391
+ - The returned dictionary includes all instance attributes, regardless of their visibility.
392
+ - Private attribute names are unmangled (class name prefix is removed).
393
+ - The result is cached in the instance to avoid redundant computation on repeated calls.
349
394
  """
350
- return {
351
- **self.getPublicAttributes(),
352
- **self.getProtectedAttributes(),
353
- **self.getPrivateAttributes(),
354
- **self.getDunderAttributes()
355
- }
395
+
396
+ # Check if the cache for attributes exists; if not, compute and store it
397
+ if not hasattr(self, "_ReflectionInstance__cacheGetAttributes"):
398
+
399
+ # Merge all attribute dictionaries from different visibility levels
400
+ self.__cacheGetAttributes = {
401
+ **self.getPublicAttributes(),
402
+ **self.getProtectedAttributes(),
403
+ **self.getPrivateAttributes(),
404
+ **self.getDunderAttributes()
405
+ }
406
+
407
+ # Return the cached dictionary of attributes
408
+ return self.__cacheGetAttributes
356
409
 
357
410
  def getPublicAttributes(self) -> Dict[str, Any]:
358
411
  """
@@ -634,24 +687,44 @@ class ReflectionInstance(IReflectionInstance):
634
687
 
635
688
  def getMethods(self) -> List[str]:
636
689
  """
637
- Get all method names of the instance.
690
+ Retrieve all method names associated with the instance, including public, protected, private,
691
+ class, and static methods.
692
+
693
+ This method aggregates method names from various categories (public, protected, private, class,
694
+ and static) by calling the corresponding getter methods. The result is cached for subsequent calls
695
+ to improve performance.
638
696
 
639
697
  Returns
640
698
  -------
641
699
  List[str]
642
- List of method names
643
- """
644
- return [
645
- *self.getPublicMethods(),
646
- *self.getProtectedMethods(),
647
- *self.getPrivateMethods(),
648
- *self.getPublicClassMethods(),
649
- *self.getProtectedClassMethods(),
650
- *self.getPrivateClassMethods(),
651
- *self.getPublicStaticMethods(),
652
- *self.getProtectedStaticMethods(),
653
- *self.getPrivateStaticMethods(),
654
- ]
700
+ A list containing the names of all methods (instance, class, and static) defined on the instance's class,
701
+ including public, protected, and private methods.
702
+
703
+ Notes
704
+ -----
705
+ - The returned list includes method names from all visibility levels (public, protected, private),
706
+ as well as class and static methods.
707
+ - The result is cached in the instance to avoid redundant computation on repeated calls.
708
+ """
709
+
710
+ # Check if the cache for method names exists; if not, compute and store it
711
+ if not hasattr(self, "_ReflectionInstance__cacheGetMethods"):
712
+
713
+ # Compute and cache the list of method names
714
+ self.__cacheGetMethods = [
715
+ *self.getPublicMethods(),
716
+ *self.getProtectedMethods(),
717
+ *self.getPrivateMethods(),
718
+ *self.getPublicClassMethods(),
719
+ *self.getProtectedClassMethods(),
720
+ *self.getPrivateClassMethods(),
721
+ *self.getPublicStaticMethods(),
722
+ *self.getProtectedStaticMethods(),
723
+ *self.getPrivateStaticMethods(),
724
+ ]
725
+
726
+ # Return the cached list of method names
727
+ return self.__cacheGetMethods
655
728
 
656
729
  def getPublicMethods(self) -> List[str]:
657
730
  """
@@ -665,11 +665,13 @@ class UnitTest(IUnitTest):
665
665
  - If a debug keyword is found, disables live console output for the test run.
666
666
  """
667
667
  try:
668
+
668
669
  # Gather method names to inspect: main test method and common setup/teardown hooks
669
- method_name = getattr(test_case, "_testMethodName", None)
670
+ rf_instance = ReflectionInstance(test_case)
671
+ method_name = rf_instance.getAttribute("_testMethodName")
670
672
  extra_methods = ["setUp", "tearDown", "onSetup", "onTeardown"]
671
673
  method_names_to_check = [method_name] if method_name else []
672
- method_names_to_check += [m for m in extra_methods if hasattr(test_case, m)]
674
+ method_names_to_check += [m for m in extra_methods if rf_instance.hasMethod(m)]
673
675
 
674
676
  # Inspect each method's source code for debug keywords
675
677
  for mname in method_names_to_check:
@@ -681,7 +683,7 @@ class UnitTest(IUnitTest):
681
683
  try:
682
684
 
683
685
  # Retrieve the source code of the method
684
- source = inspect.getsource(getattr(test_case, mname))
686
+ source = rf_instance.getSourceCode(mname)
685
687
 
686
688
  except Exception:
687
689
 
@@ -705,6 +707,7 @@ class UnitTest(IUnitTest):
705
707
  if self.__live_console is True:
706
708
  self.__live_console = False
707
709
  return True
710
+
708
711
  except Exception:
709
712
 
710
713
  # On any error during inspection, return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orionis
3
- Version: 0.611.0
3
+ Version: 0.612.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
@@ -217,7 +217,7 @@ orionis/foundation/providers/scheduler_provider.py,sha256=irwkjMiq-HpsbJxAOnhjji
217
217
  orionis/foundation/providers/testing_provider.py,sha256=2akFnabtH_cV_7z_2cCL7u8cPCGvCJAmlhMcnlCrc4c,3742
218
218
  orionis/foundation/providers/workers_provider.py,sha256=P_YtJuPNrdJAQJkAqI11KI0c6GSB9NqIuuCKpRytE0g,3937
219
219
  orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
220
- orionis/metadata/framework.py,sha256=NgXf6p9_t_5US4HUJ6ELmCMrsT1X7nankg-ixdBqB5Y,4109
220
+ orionis/metadata/framework.py,sha256=3faHOXLyiFX9kf9mI3YWJzOninqiFserHDv_3OwGUps,4109
221
221
  orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
222
222
  orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
223
223
  orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -267,7 +267,7 @@ orionis/services/introspection/callables/reflection.py,sha256=zzxrjExc2iIlfs3xfo
267
267
  orionis/services/introspection/callables/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
268
268
  orionis/services/introspection/callables/contracts/reflection.py,sha256=EZi9VfTf5GJBnMd47j_oJ8dENQ5-HzDbQ-4zSffrvpM,5523
269
269
  orionis/services/introspection/concretes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
270
- orionis/services/introspection/concretes/reflection.py,sha256=vKgkDfIbuRYH4iTcHaYoHIAMalZfGjmJ_tYTG7mhsbQ,56823
270
+ orionis/services/introspection/concretes/reflection.py,sha256=WINn-MAaMBLz36jUh26mWi_X-TMoaHfE-QhkUtBIZ4c,59768
271
271
  orionis/services/introspection/concretes/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
272
272
  orionis/services/introspection/concretes/contracts/reflection.py,sha256=LwEAgdN_WLCfS9b8pnFRVfN0PTRK4Br9qngu5km5aIk,24955
273
273
  orionis/services/introspection/dependencies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -280,7 +280,7 @@ orionis/services/introspection/dependencies/entities/resolve_argument.py,sha256=
280
280
  orionis/services/introspection/exceptions/__init__.py,sha256=uVRbnndapr9veJps8EzFJeLItxnMEbjUDdPBy3dQbeM,221
281
281
  orionis/services/introspection/exceptions/introspection.py,sha256=Qd021psWiXyY9HQVNWIBVZ3KNfHGSgq8NL4btUTR8tg,2532
282
282
  orionis/services/introspection/instances/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
283
- orionis/services/introspection/instances/reflection.py,sha256=WTkHHST8DIjKV_-DygzOsx2IA7yL5aqkr0Zn6EWm2Xo,54809
283
+ orionis/services/introspection/instances/reflection.py,sha256=RZTgrHnd_oWSZGQ2lHmsj03QkQxkzR3yuv5bg8Hl7Ck,58495
284
284
  orionis/services/introspection/instances/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
285
285
  orionis/services/introspection/instances/contracts/reflection.py,sha256=OBZ7vI6KsII76oqIF63v1I-msh94_xGfhPZQvqAVLgY,20834
286
286
  orionis/services/introspection/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -371,7 +371,7 @@ orionis/test/contracts/render.py,sha256=wpDQzUtT0r8KFZ7zPcxWHXQ1EVNKxzA_rZ6ZKUcZ
371
371
  orionis/test/contracts/test_result.py,sha256=SNXJ2UerkweYn7uCT0i0HmMGP0XBrL_9KJs-0ZvIYU4,4002
372
372
  orionis/test/contracts/unit_test.py,sha256=EyidHoOPJItwgkBWGYY1TymbNklyn2EUXnghVvW4htc,4652
373
373
  orionis/test/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
374
- orionis/test/core/unit_test.py,sha256=-kQeKqtztmWrJJxluwv52uW9LIE-rn1dbJt0L3MxfXc,71619
374
+ orionis/test/core/unit_test.py,sha256=P7AKazQWa-2TNjfqdiVEgVMpTgVn7k3l8RwO1C6Uq3w,71671
375
375
  orionis/test/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
376
376
  orionis/test/entities/result.py,sha256=eZ6UIqGmFW8FZ9x8PB_MZbLAc-SAuUyi4FUcMYIZzGo,4777
377
377
  orionis/test/enums/__init__.py,sha256=M3imAgMvKFTKg55FbtVoY3zxj7QRY9AfaUWxiSZVvn4,66
@@ -404,8 +404,8 @@ orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnI
404
404
  orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
405
405
  orionis/test/view/render.py,sha256=R55ykeRs0wDKcdTf4O1YZ8GDHTFmJ0IK6VQkbJkYUvo,5571
406
406
  orionis/test/view/report.stub,sha256=QLqqCdRoENr3ECiritRB3DO_MOjRQvgBh5jxZ3Hs1r0,28189
407
- orionis-0.611.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
408
- orionis-0.611.0.dist-info/METADATA,sha256=5nWXFpdzTFEbW_uhSwVLetqL6rVN6tNcTliHpn385Oo,4801
409
- orionis-0.611.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
410
- orionis-0.611.0.dist-info/top_level.txt,sha256=lyXi6jArpqJ-0zzNqd_uwsH-z9TCEBVBL-pC3Ekv7hU,8
411
- orionis-0.611.0.dist-info/RECORD,,
407
+ orionis-0.612.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
408
+ orionis-0.612.0.dist-info/METADATA,sha256=GaMIB8MG9eN4CaF-PjiClO-1KsVWFLY6YA9SMmeBjT0,4801
409
+ orionis-0.612.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
410
+ orionis-0.612.0.dist-info/top_level.txt,sha256=lyXi6jArpqJ-0zzNqd_uwsH-z9TCEBVBL-pC3Ekv7hU,8
411
+ orionis-0.612.0.dist-info/RECORD,,