orionis 0.204.0__py3-none-any.whl → 0.205.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.204.0"
8
+ VERSION = "0.205.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -1,7 +1,8 @@
1
- from typing import Type, TypeVar
1
+ from typing import Any, Type, Dict, List, Tuple, Callable, Optional, TypeVar, Set
2
+ import inspect
2
3
  import abc
4
+ from functools import wraps
3
5
 
4
- T = TypeVar('T')
5
6
  ABC = TypeVar('ABC', bound=abc.ABC)
6
7
 
7
8
  class ReflexionAbstract:
@@ -21,3 +22,250 @@ class ReflexionAbstract:
21
22
  def __init__(self, abstract: Type[ABC]) -> None:
22
23
  """Initialize with the abstract class."""
23
24
  self._abstract = abstract
25
+
26
+ def getClassName(self) -> str:
27
+ """Get the name of the abstract class.
28
+
29
+ Returns
30
+ -------
31
+ str
32
+ The name of the abstract class
33
+ """
34
+ return self._abstract.__name__
35
+
36
+ def getModuleName(self) -> str:
37
+ """Get the name of the module where the abstract class is defined.
38
+
39
+ Returns
40
+ -------
41
+ str
42
+ The module name
43
+ """
44
+ return self._abstract.__module__
45
+
46
+ def getAbstractMethods(self) -> Set[str]:
47
+ """Get all abstract method names required by the class.
48
+
49
+ Returns
50
+ -------
51
+ Set[str]
52
+ Set of abstract method names
53
+ """
54
+ return {name for name, _ in self._abstract.__abstractmethods__}
55
+
56
+ def getConcreteMethods(self) -> Dict[str, Callable]:
57
+ """Get all concrete methods implemented in the abstract class.
58
+
59
+ Returns
60
+ -------
61
+ Dict[str, Callable]
62
+ Dictionary of method names and their implementations
63
+ """
64
+ return {
65
+ name: member for name, member in inspect.getmembers(
66
+ self._abstract,
67
+ predicate=inspect.isfunction
68
+ ) if not name.startswith('_') and name not in self.getAbstractMethods()
69
+ }
70
+
71
+ def getStaticMethods(self) -> List[str]:
72
+ """Get all static method names of the abstract class.
73
+
74
+ Returns
75
+ -------
76
+ List[str]
77
+ List of static method names
78
+ """
79
+ return [
80
+ name for name in dir( self._abstract)
81
+ if not name.startswith('_') and
82
+ isinstance(inspect.getattr_static( self._abstract, name), staticmethod)
83
+ ]
84
+
85
+ def getClassMethods(self) -> List[str]:
86
+ """Get all class method names of the abstract class.
87
+
88
+ Returns
89
+ -------
90
+ List[str]
91
+ List of class method names
92
+ """
93
+ return [
94
+ name for name, member in inspect.getmembers(
95
+ self._abstract,
96
+ predicate=lambda x: isinstance(x, classmethod))
97
+ if not name.startswith('_')
98
+ ]
99
+
100
+ def getProperties(self) -> List[str]:
101
+ """Get all property names of the abstract class.
102
+
103
+ Returns
104
+ -------
105
+ List[str]
106
+ List of property names
107
+ """
108
+ return [
109
+ name for name, member in inspect.getmembers(
110
+ self._abstract,
111
+ predicate=lambda x: isinstance(x, property))
112
+ if not name.startswith('_')
113
+ ]
114
+
115
+ def getMethodSignature(self, methodName: str) -> inspect.Signature:
116
+ """Get the signature of a method.
117
+
118
+ Parameters
119
+ ----------
120
+ methodName : str
121
+ Name of the method
122
+
123
+ Returns
124
+ -------
125
+ inspect.Signature
126
+ The method signature
127
+
128
+ Raises
129
+ ------
130
+ AttributeError
131
+ If the method doesn't exist
132
+ """
133
+ method = getattr(self._abstract, methodName)
134
+ return inspect.signature(method)
135
+
136
+ def getDocstring(self) -> Optional[str]:
137
+ """Get the docstring of the abstract class.
138
+
139
+ Returns
140
+ -------
141
+ Optional[str]
142
+ The class docstring
143
+ """
144
+ return self._abstract.__doc__
145
+
146
+ def getBaseAbstractClasses(self) -> Tuple[Type[ABC], ...]:
147
+ """Get the abstract base classes.
148
+
149
+ Returns
150
+ -------
151
+ Tuple[Type[ABC], ...]
152
+ Tuple of abstract base classes
153
+ """
154
+ return tuple(
155
+ base for base in self._abstract.__bases__
156
+ if inspect.isabstract(base)
157
+ )
158
+
159
+ def getInterfaceMethods(self) -> Dict[str, inspect.Signature]:
160
+ """Get all abstract methods with their signatures.
161
+
162
+ Returns
163
+ -------
164
+ Dict[str, inspect.Signature]
165
+ Dictionary of method names and their signatures
166
+ """
167
+ return {
168
+ name: inspect.signature(getattr(self._abstract, name))
169
+ for name in self.getAbstractMethods()
170
+ }
171
+
172
+ def isSubclassOf(self, abstract_class: Type[ABC]) -> bool:
173
+ """Check if the abstract class inherits from another abstract class.
174
+
175
+ Parameters
176
+ ----------
177
+ abstract_class : Type[ABC]
178
+ The abstract class to check against
179
+
180
+ Returns
181
+ -------
182
+ bool
183
+ True if this is a subclass
184
+ """
185
+ return issubclass(self._abstract, abstract_class)
186
+
187
+ def getSourceCode(self) -> Optional[str]:
188
+ """Get the source code of the abstract class.
189
+
190
+ Returns
191
+ -------
192
+ Optional[str]
193
+ The source code if available
194
+ """
195
+ try:
196
+ return inspect.getsource(self._abstract)
197
+ except (TypeError, OSError):
198
+ return None
199
+
200
+ def getFileLocation(self) -> Optional[str]:
201
+ """Get the file location where the abstract class is defined.
202
+
203
+ Returns
204
+ -------
205
+ Optional[str]
206
+ The file path if available
207
+ """
208
+ try:
209
+ return inspect.getfile(self._abstract)
210
+ except (TypeError, OSError):
211
+ return None
212
+
213
+ def getAnnotations(self) -> Dict[str, Any]:
214
+ """Get type annotations of the abstract class.
215
+
216
+ Returns
217
+ -------
218
+ Dict[str, Any]
219
+ Dictionary of attribute names and their type annotations
220
+ """
221
+ return self._abstract.__annotations__
222
+
223
+ def getDecorators(self, method_name: str) -> List[Callable]:
224
+ """Get decorators applied to a method.
225
+
226
+ Parameters
227
+ ----------
228
+ method_name : str
229
+ Name of the method
230
+
231
+ Returns
232
+ -------
233
+ List[Callable]
234
+ List of decorator functions
235
+ """
236
+ method = getattr(self._abstract, method_name)
237
+ decorators = []
238
+
239
+ if hasattr(method, '__wrapped__'):
240
+ # Unwrap decorated functions
241
+ while hasattr(method, '__wrapped__'):
242
+ decorators.append(method)
243
+ method = method.__wrapped__
244
+
245
+ return decorators
246
+
247
+ def isProtocol(self) -> bool:
248
+ """Check if the abstract class is a Protocol.
249
+
250
+ Returns
251
+ -------
252
+ bool
253
+ True if this is a Protocol class
254
+ """
255
+ return hasattr(self._abstract, '_is_protocol') and self._abstract._is_protocol
256
+
257
+ def getRequiredAttributes(self) -> Set[str]:
258
+ """For Protocol classes, get required attributes.
259
+
260
+ Returns
261
+ -------
262
+ Set[str]
263
+ Set of required attribute names
264
+ """
265
+ if not self.isProtocol():
266
+ return set()
267
+
268
+ return {
269
+ name for name in dir(self._abstract)
270
+ if not name.startswith('_') and not inspect.isfunction(getattr(self._abstract, name))
271
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.204.0
3
+ Version: 0.205.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=fJPN2FnUX2ZiLCd2YqzdQCQJjBCPgXa-f7e91XLCcoA,1469
3
+ orionis/framework.py,sha256=fUxv8sJtO5v-ERZPJzgKhGDePNz3AbKp-n-HE7IIhZo,1469
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
@@ -171,7 +171,7 @@ orionis/luminate/support/inspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
171
171
  orionis/luminate/support/inspection/container_integrity.py,sha256=6d9FsGk-Rm1AXgqBS3Nww49dR7n1ptXTTNyGUuBHgNY,10111
172
172
  orionis/luminate/support/inspection/functions.py,sha256=XVDLdygONcfDNlH7CZ6muNdtYHLgNp5RybqC3smL4Y4,6400
173
173
  orionis/luminate/support/inspection/reflection.py,sha256=x_UHBY9pBSKgct13-u1WbhoONqLoGG60OpgoCsKE0AI,20368
174
- orionis/luminate/support/inspection/reflexion_abstract.py,sha256=T3Zsi2KT2cS2-Upu0NDcW5FTrcytTLxlmBfZ_KAYA3Y,554
174
+ orionis/luminate/support/inspection/reflexion_abstract.py,sha256=yZTl_oZACjlXKKPmQimGsfre3qQUO2hbNDf7PJ4gKZE,7661
175
175
  orionis/luminate/support/inspection/reflexion_concrete.py,sha256=0WOlLeTWLwMeAUReoaJetqlnT1_TxW_jMnbk_yXRR0g,549
176
176
  orionis/luminate/support/inspection/reflexion_concrete_with_abstract.py,sha256=ZuAFoSPkgbOFMIbVR0hvlkKsm1dIpY1_bsXxZxvXcmU,801
177
177
  orionis/luminate/support/inspection/reflexion_instance.py,sha256=k6bpRYjLeTUDqquluYrDZUtBLpLuGe4wm7PMUM8Sz-E,9914
@@ -195,17 +195,16 @@ orionis/static/logos/OrionisFramework.psd,sha256=QFMRe_HENaIgQi9VWMvNV3OHKOFofFG
195
195
  orionis/static/logos/OrionisFramework2.png,sha256=Z_-yBHNSo33QeSTyi-8GfiFozdRqUomIZ28bGx6Py5c,256425
196
196
  orionis/static/logos/OrionisFramework3.png,sha256=BPG9ZB58vDALavI9OMmr8Ym0DQa44s5NL_3M4M6dIYs,193734
197
197
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
198
- tests/main.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
199
198
  tests/example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
200
- tests/example/test_example.py,sha256=IyhepxT7QPQcV2IYGuUDBWgd6sqDSko4-kImbRgqLX4,558
199
+ tests/example/test_example.py,sha256=MNYissCEa0mzx1YA2gTiqXRX8r2v_vfB_Ew0jBFmBag,556
201
200
  tests/support/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
202
201
  tests/support/inspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
203
- tests/support/inspection/test_reflection.py,sha256=GhGtSJIsWQAthsHPattpmjTboQtwUlTCKct9PX5S8gI,7244
202
+ tests/support/inspection/test_reflection_instance.py,sha256=aYi4qmuAzQ4-gAUrtc9Lx6gNR4Mw4GcOF_T8iWsWZoQ,7266
204
203
  tests/support/inspection/fakes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
205
204
  tests/support/inspection/fakes/fake_reflection.py,sha256=G16rZdJWC3L8SGEQkmwktvw4n7IAusIIx9Tm-ZFLcg4,1419
206
- orionis-0.204.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
207
- orionis-0.204.0.dist-info/METADATA,sha256=M3YrdUwxrIdbbcnYK7nGdBj-xh3DNh7fUJQzY-BD0U0,3003
208
- orionis-0.204.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
209
- orionis-0.204.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
210
- orionis-0.204.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
211
- orionis-0.204.0.dist-info/RECORD,,
205
+ orionis-0.205.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
206
+ orionis-0.205.0.dist-info/METADATA,sha256=aFCgP3-K5OmZ5KziS4bEwafD_YPA4RxPvIZHjYCIHb0,3003
207
+ orionis-0.205.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
208
+ orionis-0.205.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
209
+ orionis-0.205.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
210
+ orionis-0.205.0.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  import unittest
2
-
3
2
  class TestExample(unittest.TestCase):
4
3
  """
5
4
  Unit tests for basic example functionality.
@@ -132,8 +132,8 @@ class TestReflection(unittest.TestCase, PrinterInTest):
132
132
  """Test that Reflection.instance returns an instance of ReflexionInstance."""
133
133
 
134
134
  # Create a new macro function
135
- def myMacro(cls, num):
136
- return cls.public_attr + num
135
+ def myMacro(cls:FakeClass, num):
136
+ return cls.instance_method(10, 12) + num
137
137
 
138
138
  # Create an instance of FakeClass and set the macro as an attribute
139
139
  reflex = Reflection.instance(FakeClass())
@@ -144,4 +144,4 @@ class TestReflection(unittest.TestCase, PrinterInTest):
144
144
 
145
145
  # Call the macro method and check the result
146
146
  result = reflex.callMethod("myMacro", reflex._instance, 3)
147
- self.assertEqual(result, 45)
147
+ self.assertEqual(result, 25)
tests/main.py DELETED
File without changes