orionis 0.213.1__py3-none-any.whl → 0.216.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/console/output/console.py +2 -2
- orionis/luminate/support/inspection/contracts/__init__.py +0 -0
- orionis/luminate/support/inspection/contracts/reflection.py +187 -0
- orionis/luminate/support/inspection/contracts/reflexion_abstract.py +265 -0
- orionis/luminate/support/inspection/reflection.py +2 -1
- orionis/luminate/support/inspection/reflexion_abstract.py +2 -1
- orionis/luminate/support/parsers/__init__.py +0 -0
- orionis/luminate/support/parsers/contracts/__init__.py +0 -0
- orionis/luminate/support/parsers/contracts/exception_parser.py +38 -0
- orionis/luminate/support/parsers/exception_parser.py +107 -0
- orionis/luminate/support/standard/__init__.py +0 -0
- orionis/luminate/support/standard/contracts/__init__.py +0 -0
- orionis/luminate/support/standard/contracts/std.py +127 -0
- orionis/luminate/support/standard/std.py +137 -0
- {orionis-0.213.1.dist-info → orionis-0.216.0.dist-info}/METADATA +1 -1
- {orionis-0.213.1.dist-info → orionis-0.216.0.dist-info}/RECORD +27 -14
- tests/support/parsers/__init__.py +0 -0
- tests/support/parsers/fakes/__init__.py +0 -0
- tests/support/parsers/fakes/fake_custom_error.py +27 -0
- tests/support/parsers/test_exception_parser.py +59 -0
- tests/support/standard/__init__.py +0 -0
- tests/support/standard/test_std.py +58 -0
- orionis/luminate/contracts/support/std.py +0 -43
- orionis/luminate/support/exception_parse.py +0 -47
- orionis/luminate/support/reflection.py +0 -390
- orionis/luminate/support/std.py +0 -53
- {orionis-0.213.1.dist-info → orionis-0.216.0.dist-info}/LICENCE +0 -0
- {orionis-0.213.1.dist-info → orionis-0.216.0.dist-info}/WHEEL +0 -0
- {orionis-0.213.1.dist-info → orionis-0.216.0.dist-info}/entry_points.txt +0 -0
- {orionis-0.213.1.dist-info → orionis-0.216.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,127 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
from typing import Any, Dict
|
3
|
+
|
4
|
+
class IStdClass(ABC):
|
5
|
+
"""
|
6
|
+
Interface for a dynamic class that allows setting arbitrary attributes,
|
7
|
+
similar to PHP's stdClass.
|
8
|
+
|
9
|
+
Implementations should provide dynamic attribute access and management.
|
10
|
+
"""
|
11
|
+
|
12
|
+
@abstractmethod
|
13
|
+
def __init__(self, **kwargs: Any) -> None:
|
14
|
+
"""
|
15
|
+
Initializes the object with optional attributes.
|
16
|
+
|
17
|
+
Parameters
|
18
|
+
----------
|
19
|
+
kwargs : Any
|
20
|
+
Key-value pairs to set as initial attributes.
|
21
|
+
"""
|
22
|
+
pass
|
23
|
+
|
24
|
+
@abstractmethod
|
25
|
+
def __repr__(self) -> str:
|
26
|
+
"""
|
27
|
+
Returns an unambiguous string representation of the object.
|
28
|
+
|
29
|
+
Returns
|
30
|
+
-------
|
31
|
+
str
|
32
|
+
A string that could be used to recreate the object.
|
33
|
+
"""
|
34
|
+
pass
|
35
|
+
|
36
|
+
@abstractmethod
|
37
|
+
def __str__(self) -> str:
|
38
|
+
"""
|
39
|
+
Returns a readable string representation of the object.
|
40
|
+
|
41
|
+
Returns
|
42
|
+
-------
|
43
|
+
str
|
44
|
+
A user-friendly string showing the object's attributes.
|
45
|
+
"""
|
46
|
+
pass
|
47
|
+
|
48
|
+
@abstractmethod
|
49
|
+
def __eq__(self, other: Any) -> bool:
|
50
|
+
"""
|
51
|
+
Compares two objects for equality based on their attributes.
|
52
|
+
|
53
|
+
Parameters
|
54
|
+
----------
|
55
|
+
other : Any
|
56
|
+
The object to compare with.
|
57
|
+
|
58
|
+
Returns
|
59
|
+
-------
|
60
|
+
bool
|
61
|
+
True if both objects have the same attributes and values.
|
62
|
+
"""
|
63
|
+
pass
|
64
|
+
|
65
|
+
@abstractmethod
|
66
|
+
def toDict(self) -> Dict[str, Any]:
|
67
|
+
"""
|
68
|
+
Converts the object's attributes to a dictionary.
|
69
|
+
|
70
|
+
Returns
|
71
|
+
-------
|
72
|
+
Dict[str, Any]
|
73
|
+
A dictionary representation of the object's attributes.
|
74
|
+
"""
|
75
|
+
pass
|
76
|
+
|
77
|
+
@abstractmethod
|
78
|
+
def update(self, **kwargs: Any) -> None:
|
79
|
+
"""
|
80
|
+
Updates the object's attributes dynamically.
|
81
|
+
|
82
|
+
Parameters
|
83
|
+
----------
|
84
|
+
kwargs : Any
|
85
|
+
Key-value pairs to update attributes.
|
86
|
+
|
87
|
+
Raises
|
88
|
+
------
|
89
|
+
ValueError
|
90
|
+
If an attribute name is invalid or conflicts with existing methods.
|
91
|
+
"""
|
92
|
+
pass
|
93
|
+
|
94
|
+
@abstractmethod
|
95
|
+
def remove(self, *attributes: str) -> None:
|
96
|
+
"""
|
97
|
+
Removes one or more attributes from the object.
|
98
|
+
|
99
|
+
Parameters
|
100
|
+
----------
|
101
|
+
*attributes : str
|
102
|
+
Names of the attributes to remove.
|
103
|
+
|
104
|
+
Raises
|
105
|
+
------
|
106
|
+
AttributeError
|
107
|
+
If any of the attributes doesn't exist.
|
108
|
+
"""
|
109
|
+
pass
|
110
|
+
|
111
|
+
@classmethod
|
112
|
+
@abstractmethod
|
113
|
+
def from_dict(cls, dictionary: Dict[str, Any]) -> 'IStdClass':
|
114
|
+
"""
|
115
|
+
Creates an instance from a dictionary.
|
116
|
+
|
117
|
+
Parameters
|
118
|
+
----------
|
119
|
+
dictionary : Dict[str, Any]
|
120
|
+
Dictionary to create the object from.
|
121
|
+
|
122
|
+
Returns
|
123
|
+
-------
|
124
|
+
IStdClass
|
125
|
+
A new instance with the dictionary's key-value pairs as attributes.
|
126
|
+
"""
|
127
|
+
pass
|
@@ -0,0 +1,137 @@
|
|
1
|
+
from orionis.luminate.support.standard.contracts.std import IStdClass
|
2
|
+
|
3
|
+
class StdClass(IStdClass):
|
4
|
+
"""
|
5
|
+
A dynamic class that allows setting arbitrary attributes,
|
6
|
+
similar to PHP's stdClass.
|
7
|
+
|
8
|
+
Examples
|
9
|
+
--------
|
10
|
+
>>> obj = StdClass(name='Raul', age=30)
|
11
|
+
>>> obj.name
|
12
|
+
'Raul'
|
13
|
+
>>> obj.update(age=31)
|
14
|
+
>>> obj.toDict()
|
15
|
+
{'name': 'Raul', 'age': 31}
|
16
|
+
"""
|
17
|
+
|
18
|
+
def __init__(self, **kwargs):
|
19
|
+
"""
|
20
|
+
Initializes the StdClass with optional keyword arguments.
|
21
|
+
|
22
|
+
Parameters
|
23
|
+
----------
|
24
|
+
kwargs : dict
|
25
|
+
Key-value pairs to set as attributes.
|
26
|
+
"""
|
27
|
+
self.update(**kwargs)
|
28
|
+
|
29
|
+
def __repr__(self):
|
30
|
+
"""
|
31
|
+
Returns an unambiguous string representation of the object.
|
32
|
+
|
33
|
+
Returns
|
34
|
+
-------
|
35
|
+
str
|
36
|
+
A string that could be used to recreate the object.
|
37
|
+
"""
|
38
|
+
return f"{self.__class__.__name__}({self.__dict__})"
|
39
|
+
|
40
|
+
def __str__(self):
|
41
|
+
"""
|
42
|
+
Returns a readable string representation of the object.
|
43
|
+
|
44
|
+
Returns
|
45
|
+
-------
|
46
|
+
str
|
47
|
+
A user-friendly string showing the object's attributes.
|
48
|
+
"""
|
49
|
+
return str(self.__dict__)
|
50
|
+
|
51
|
+
def __eq__(self, other):
|
52
|
+
"""
|
53
|
+
Compares two StdClass objects for equality based on their attributes.
|
54
|
+
|
55
|
+
Parameters
|
56
|
+
----------
|
57
|
+
other : object
|
58
|
+
The object to compare with.
|
59
|
+
|
60
|
+
Returns
|
61
|
+
-------
|
62
|
+
bool
|
63
|
+
True if both objects have the same attributes and values.
|
64
|
+
"""
|
65
|
+
if not isinstance(other, StdClass):
|
66
|
+
return False
|
67
|
+
return self.__dict__ == other.__dict__
|
68
|
+
|
69
|
+
def toDict(self):
|
70
|
+
"""
|
71
|
+
Converts the object's attributes to a dictionary.
|
72
|
+
|
73
|
+
Returns
|
74
|
+
-------
|
75
|
+
dict
|
76
|
+
A dictionary representation of the object's attributes.
|
77
|
+
"""
|
78
|
+
|
79
|
+
# Return a copy to avoid external modifications
|
80
|
+
return self.__dict__.copy()
|
81
|
+
|
82
|
+
def update(self, **kwargs):
|
83
|
+
"""
|
84
|
+
Updates the object's attributes dynamically.
|
85
|
+
|
86
|
+
Parameters
|
87
|
+
----------
|
88
|
+
kwargs : dict
|
89
|
+
Key-value pairs to update attributes.
|
90
|
+
|
91
|
+
Raises
|
92
|
+
------
|
93
|
+
ValueError
|
94
|
+
If an attribute name is invalid or conflicts with existing methods.
|
95
|
+
"""
|
96
|
+
for key, value in kwargs.items():
|
97
|
+
if key.startswith('__') and key.endswith('__'):
|
98
|
+
raise ValueError(f"Cannot set attribute with reserved name: {key}")
|
99
|
+
if hasattr(self.__class__, key):
|
100
|
+
raise ValueError(f"Cannot set attribute '{key}' as it conflicts with a class method")
|
101
|
+
setattr(self, key, value)
|
102
|
+
|
103
|
+
def remove(self, *attributes):
|
104
|
+
"""
|
105
|
+
Removes one or more attributes from the object.
|
106
|
+
|
107
|
+
Parameters
|
108
|
+
----------
|
109
|
+
*attributes : str
|
110
|
+
Names of the attributes to remove.
|
111
|
+
|
112
|
+
Raises
|
113
|
+
------
|
114
|
+
AttributeError
|
115
|
+
If any of the attributes doesn't exist.
|
116
|
+
"""
|
117
|
+
for attr in attributes:
|
118
|
+
if not hasattr(self, attr):
|
119
|
+
raise AttributeError(f"Attribute '{attr}' not found")
|
120
|
+
delattr(self, attr)
|
121
|
+
|
122
|
+
@classmethod
|
123
|
+
def from_dict(cls, dictionary):
|
124
|
+
"""
|
125
|
+
Creates a StdClass instance from a dictionary.
|
126
|
+
|
127
|
+
Parameters
|
128
|
+
----------
|
129
|
+
dictionary : dict
|
130
|
+
Dictionary to create the object from.
|
131
|
+
|
132
|
+
Returns
|
133
|
+
-------
|
134
|
+
StdClass
|
135
|
+
A new StdClass instance with the dictionary's key-value pairs as attributes.
|
136
|
+
"""
|
137
|
+
return cls(**dictionary)
|
@@ -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=GQEposKTRMRQV49FKtBLhhmOc6z7-SAsQVK3KpYHHgM,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
|
@@ -39,7 +39,7 @@ orionis/luminate/console/exceptions/cli_exception.py,sha256=HsZ_vSeNiJWQ0gznVFNc
|
|
39
39
|
orionis/luminate/console/exceptions/cli_runtime_error.py,sha256=DaCDGu6mXBk1LIzc7cwRROw1mePAigPNASjNZHhUSBE,1154
|
40
40
|
orionis/luminate/console/exceptions/cli_schedule_exception.py,sha256=IBbXb_5zi02pyo1laHdjGn6FYZK7WWRp4j2fkZOCT6I,1161
|
41
41
|
orionis/luminate/console/output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
42
|
-
orionis/luminate/console/output/console.py,sha256=
|
42
|
+
orionis/luminate/console/output/console.py,sha256=FuNlI2sjmv14iYM80YQ3jMeUcVaNv0VqBhnfVdFEChA,18209
|
43
43
|
orionis/luminate/console/output/executor.py,sha256=-efhCbWOS4ZqmRsO0s3j5NEbw4I9hVROF8Q3Atx77zs,3369
|
44
44
|
orionis/luminate/console/output/progress_bar.py,sha256=ZiPGcUaN3EINeLRKgLGtS1GAb1XWlCDx7wFQ7Ff0hqY,3096
|
45
45
|
orionis/luminate/console/output/styles.py,sha256=6a4oQCOBOKMh2ARdeq5GlIskJ3wjiylYmh66tUKKmpQ,4053
|
@@ -107,7 +107,6 @@ orionis/luminate/contracts/services/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5J
|
|
107
107
|
orionis/luminate/contracts/services/log/log_service.py,sha256=1RD3u-a5ZDMbg7AYE8y2SW8QNRybAU3De0mEA0dAeNo,2167
|
108
108
|
orionis/luminate/contracts/support/exception_parse.py,sha256=P7yh5Q3KIcRPAZeg6190XbOSvu5XBK-VVt6zHxaiexw,779
|
109
109
|
orionis/luminate/contracts/support/reflection.py,sha256=Ht5_FsFbCb-APRXX3HdsfKl3cDZU8DyXGXPWKTn05uQ,8429
|
110
|
-
orionis/luminate/contracts/support/std.py,sha256=IihREHnJ_D2LqsrwtnGsIRYr0UsJsQezYPSPO6UaBQ4,992
|
111
110
|
orionis/luminate/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
112
111
|
orionis/luminate/facades/app_facade.py,sha256=UzZ4n7N_Gz5MgYJvLethVUTp4gmYlubriYGtPXUxQxQ,893
|
113
112
|
orionis/luminate/facades/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -162,20 +161,28 @@ orionis/luminate/services/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
162
161
|
orionis/luminate/services/log/log_service.py,sha256=jrCrKz7Uj6n_ri-v5A4YOILQGUQ9MAmrlSizbbOvKhI,8303
|
163
162
|
orionis/luminate/support/asyn_run.py,sha256=MTwVGNEnKRqD582oZRpUDQ141-hXoO5wc4NSdC7ct0E,1114
|
164
163
|
orionis/luminate/support/dot_dict.py,sha256=FVHfBuAGTTVMjNG01Fix645fRNKKUMmNx61pYkxPL5c,1253
|
165
|
-
orionis/luminate/support/exception_parse.py,sha256=S4KU0s-MCEbulPrf0N9tLZZIN3Sjn-tOKYtQCP0Xe0k,1655
|
166
|
-
orionis/luminate/support/reflection.py,sha256=TbWZ_cer0PXrPlwCYFbUJRymlzYxXT0E4C5XCsSc3mw,11951
|
167
|
-
orionis/luminate/support/std.py,sha256=TqrgMxF_i5ubYGT5LOvHCH7HOHNmI8CE1kG9pNoSniY,1390
|
168
164
|
orionis/luminate/support/inspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
169
165
|
orionis/luminate/support/inspection/container_integrity.py,sha256=6d9FsGk-Rm1AXgqBS3Nww49dR7n1ptXTTNyGUuBHgNY,10111
|
170
166
|
orionis/luminate/support/inspection/functions.py,sha256=4wDT7iNp-5l4vuHk0UsIxN9wakASJRD4V0KY24uMDzk,7227
|
171
|
-
orionis/luminate/support/inspection/reflection.py,sha256=
|
172
|
-
orionis/luminate/support/inspection/reflexion_abstract.py,sha256=
|
167
|
+
orionis/luminate/support/inspection/reflection.py,sha256=xUILK5eEkTqXiAaOWVjEn_u-ybQyDMRxDE2Vn2aTYGU,7800
|
168
|
+
orionis/luminate/support/inspection/reflexion_abstract.py,sha256=nImlP07TpsT0azgIafGVZfSv1THrBoJOlNSSr9vDKiE,10848
|
173
169
|
orionis/luminate/support/inspection/reflexion_concrete.py,sha256=1ISuy2L6Oser-EhmpuGALmbauh7Z-X8Rx1YYgt5CabQ,7543
|
174
170
|
orionis/luminate/support/inspection/reflexion_concrete_with_abstract.py,sha256=z1cAscuG6a1E4ZJmwkp9HVQ0yhTAeFYKfnnyR_M-RFI,7480
|
175
171
|
orionis/luminate/support/inspection/reflexion_instance.py,sha256=LNAgw4sZvHT7UMiObHTGk7xgqpIeKYHAQRgRpuPfEas,10842
|
176
172
|
orionis/luminate/support/inspection/reflexion_instance_with_abstract.py,sha256=PI_VSH8baxjPgheOYc9tQAlLq9mjxGm5zCOr-bLVksg,9406
|
177
173
|
orionis/luminate/support/inspection/reflexion_module.py,sha256=OgBXpqNJHkmq-gX4rqFStv-WVNe9R38RsgUgfHpak8k,405
|
178
174
|
orionis/luminate/support/inspection/reflexion_module_with_classname.py,sha256=YZHZI0XUZkSWnq9wrGxrIXtI64nY9yVSZoMe7PZXq8Y,620
|
175
|
+
orionis/luminate/support/inspection/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
176
|
+
orionis/luminate/support/inspection/contracts/reflection.py,sha256=zF9OLiEdgWJtJWvfrmWCQhbDjgYmm-QvAkFv9OLb3rE,4959
|
177
|
+
orionis/luminate/support/inspection/contracts/reflexion_abstract.py,sha256=u8SiBTvcWltwR9g64akCNCzsTq8YkkZIPPEPwbyroQU,6396
|
178
|
+
orionis/luminate/support/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
179
|
+
orionis/luminate/support/parsers/exception_parser.py,sha256=6MTeql76c1Muh9Nn-jz2jJdzb9_F7SLdoFjqBD5F8lY,3642
|
180
|
+
orionis/luminate/support/parsers/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
181
|
+
orionis/luminate/support/parsers/contracts/exception_parser.py,sha256=HcWN7nJrvD7xLREPKEnBhyG30IkkAB7Bx_hGpcfb0ZE,912
|
182
|
+
orionis/luminate/support/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
183
|
+
orionis/luminate/support/standard/std.py,sha256=AlhDc0CXC8_TSfZfkodefl_MwCyauX2E3CUXJF6_55w,3761
|
184
|
+
orionis/luminate/support/standard/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
185
|
+
orionis/luminate/support/standard/contracts/std.py,sha256=x9sVir2yg4hve56cCklIdVSr8utruIO_sUdlTNfZ1Ds,3109
|
179
186
|
orionis/luminate/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
180
187
|
orionis/luminate/test/test_case.py,sha256=jFhNcUZWuDTDFpe_nYJTqXQChA4z5kxu0I2YCONGSVk,134
|
181
188
|
orionis/luminate/test/test_exception.py,sha256=21PILTXnMuL5-wT3HGKjIklt8VeIYDcQDN346i-BbJw,1336
|
@@ -209,9 +216,15 @@ tests/support/inspection/fakes/fake_reflection_concrete.py,sha256=j6gzsxE3xq5oJ3
|
|
209
216
|
tests/support/inspection/fakes/fake_reflection_concrete_with_abstract.py,sha256=ibCjrtNM6BMf5Z5VMvat7E6zOAk5g9z--gj4ykKJWY8,2118
|
210
217
|
tests/support/inspection/fakes/fake_reflection_instance.py,sha256=G16rZdJWC3L8SGEQkmwktvw4n7IAusIIx9Tm-ZFLcg4,1419
|
211
218
|
tests/support/inspection/fakes/fake_reflection_instance_with_abstract.py,sha256=SfL8FuFmr650RlzXTrP4tGMfsPVZLhOxVnBXu_g1POg,1471
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
219
|
+
tests/support/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
220
|
+
tests/support/parsers/test_exception_parser.py,sha256=vSbSDAGH0TFIP4C6xfCecOgQYP-Aibqrb3K8ewWig0c,2339
|
221
|
+
tests/support/parsers/fakes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
222
|
+
tests/support/parsers/fakes/fake_custom_error.py,sha256=BD8tQPhmIYFYVcaeMpEQ6uK1d6pcU4EGbwRkVfCZp7c,802
|
223
|
+
tests/support/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
224
|
+
tests/support/standard/test_std.py,sha256=PSM-AXDxvzJurAO7TfLdnq-W1oUMX6bWThNCGJCFAm4,1900
|
225
|
+
orionis-0.216.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
226
|
+
orionis-0.216.0.dist-info/METADATA,sha256=7d93eflVGbnXtk6z9hAKh_o5mdFO7aMYW6dFcxV_QmU,3003
|
227
|
+
orionis-0.216.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
228
|
+
orionis-0.216.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
|
229
|
+
orionis-0.216.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
230
|
+
orionis-0.216.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class CustomError(Exception):
|
2
|
+
"""
|
3
|
+
A custom exception class for handling errors with an optional error code.
|
4
|
+
|
5
|
+
Parameters
|
6
|
+
----------
|
7
|
+
message : str
|
8
|
+
The error message describing the exception.
|
9
|
+
code : int, optional
|
10
|
+
An optional error code associated with the exception (default is None).
|
11
|
+
|
12
|
+
Attributes
|
13
|
+
----------
|
14
|
+
code : int or None
|
15
|
+
The error code associated with the exception, if provided.
|
16
|
+
|
17
|
+
Examples
|
18
|
+
--------
|
19
|
+
>>> try:
|
20
|
+
... raise CustomError("An error occurred", code=404)
|
21
|
+
... except CustomError as e:
|
22
|
+
... print(f"Error: {e}, Code: {e.code}")
|
23
|
+
Error: An error occurred, Code: 404
|
24
|
+
"""
|
25
|
+
def __init__(self, message, code=None):
|
26
|
+
super().__init__(message)
|
27
|
+
self.code = code
|
@@ -0,0 +1,59 @@
|
|
1
|
+
from orionis.luminate.support.parsers.exception_parser import ExceptionParser
|
2
|
+
from orionis.luminate.test.test_case import TestCase
|
3
|
+
from tests.support.parsers.fakes.fake_custom_error import CustomError
|
4
|
+
|
5
|
+
class TestsExceptionParser(TestCase):
|
6
|
+
|
7
|
+
def testBasicExceptionStructure(self):
|
8
|
+
"""
|
9
|
+
Ensure that the ExceptionParser correctly structures a basic exception.
|
10
|
+
"""
|
11
|
+
try:
|
12
|
+
raise ValueError("Something went wrong")
|
13
|
+
except Exception as e:
|
14
|
+
result = ExceptionParser(e).toDict()
|
15
|
+
|
16
|
+
self.assertIsInstance(result, dict)
|
17
|
+
self.assertIn("error_type", result)
|
18
|
+
self.assertIn("error_message", result)
|
19
|
+
self.assertIn("stack_trace", result)
|
20
|
+
self.assertIn("error_code", result)
|
21
|
+
self.assertIn("cause", result)
|
22
|
+
|
23
|
+
self.assertEqual(result["error_type"], "ValueError")
|
24
|
+
self.assertTrue("Something went wrong" in result["error_message"])
|
25
|
+
self.assertIsNone(result["error_code"])
|
26
|
+
self.assertIsNone(result["cause"])
|
27
|
+
self.assertIsInstance(result["stack_trace"], list)
|
28
|
+
self.assertGreater(len(result["stack_trace"]), 0)
|
29
|
+
|
30
|
+
def testRawExceptionProperty(self):
|
31
|
+
"""
|
32
|
+
Ensure that the raw_exception property returns the original exception.
|
33
|
+
"""
|
34
|
+
try:
|
35
|
+
raise RuntimeError("Test exception")
|
36
|
+
except Exception as e:
|
37
|
+
parser = ExceptionParser(e)
|
38
|
+
self.assertIs(parser.raw_exception, e)
|
39
|
+
|
40
|
+
def testExceptionWithCode(self):
|
41
|
+
try:
|
42
|
+
raise CustomError("Custom message", code=404)
|
43
|
+
except Exception as e:
|
44
|
+
result = ExceptionParser(e).toDict()
|
45
|
+
self.assertEqual(result["error_code"], 404)
|
46
|
+
self.assertEqual(result["error_type"], "CustomError")
|
47
|
+
|
48
|
+
def testNestedExceptionCause(self):
|
49
|
+
"""
|
50
|
+
Ensure that the ExceptionParser correctly handles nested exceptions.
|
51
|
+
"""
|
52
|
+
try:
|
53
|
+
try:
|
54
|
+
raise ValueError("Original cause")
|
55
|
+
except ValueError as exc:
|
56
|
+
raise TypeError("Outer error")
|
57
|
+
except Exception as e:
|
58
|
+
result = ExceptionParser(e).toDict()
|
59
|
+
self.assertEqual(result["error_type"], "TypeError")
|
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
from orionis.luminate.support.standard.std import StdClass
|
2
|
+
from orionis.luminate.test.test_case import TestCase
|
3
|
+
|
4
|
+
class TestStdClass(TestCase):
|
5
|
+
|
6
|
+
def testInitializationAndAccess(self):
|
7
|
+
obj = StdClass(name='Raul', age=30)
|
8
|
+
self.assertEqual(obj.name, 'Raul')
|
9
|
+
self.assertEqual(obj.age, 30)
|
10
|
+
|
11
|
+
def testToDictReturnsCorrectData(self):
|
12
|
+
obj = StdClass(a=1, b=2)
|
13
|
+
expected = {'a': 1, 'b': 2}
|
14
|
+
self.assertEqual(obj.toDict(), expected)
|
15
|
+
|
16
|
+
def testUpdateAttributes(self):
|
17
|
+
obj = StdClass()
|
18
|
+
obj.update(foo='bar', number=42)
|
19
|
+
self.assertEqual(obj.foo, 'bar')
|
20
|
+
self.assertEqual(obj.number, 42)
|
21
|
+
|
22
|
+
def testUpdateReservedAttributeRaisesError(self):
|
23
|
+
obj = StdClass()
|
24
|
+
with self.assertRaises(ValueError):
|
25
|
+
obj.update(__init__='bad')
|
26
|
+
|
27
|
+
def testUpdateConflictingAttributeRaisesError(self):
|
28
|
+
obj = StdClass()
|
29
|
+
with self.assertRaises(ValueError):
|
30
|
+
obj.update(toDict='oops')
|
31
|
+
|
32
|
+
def testRemoveExistingAttributes(self):
|
33
|
+
obj = StdClass(x=1, y=2)
|
34
|
+
obj.remove('x')
|
35
|
+
self.assertFalse(hasattr(obj, 'x'))
|
36
|
+
self.assertTrue(hasattr(obj, 'y'))
|
37
|
+
|
38
|
+
def testRemoveNonExistingAttributeRaisesError(self):
|
39
|
+
obj = StdClass()
|
40
|
+
with self.assertRaises(AttributeError):
|
41
|
+
obj.remove('not_there')
|
42
|
+
|
43
|
+
def testFromDictCreatesEquivalentInstance(self):
|
44
|
+
data = {'a': 10, 'b': 20}
|
45
|
+
obj = StdClass.from_dict(data)
|
46
|
+
self.assertEqual(obj.toDict(), data)
|
47
|
+
|
48
|
+
def testReprAndStr(self):
|
49
|
+
obj = StdClass(x=5)
|
50
|
+
self.assertIn("StdClass", repr(obj))
|
51
|
+
self.assertIn("'x': 5", str(obj))
|
52
|
+
|
53
|
+
def testEquality(self):
|
54
|
+
a = StdClass(x=1, y=2)
|
55
|
+
b = StdClass(x=1, y=2)
|
56
|
+
c = StdClass(x=3)
|
57
|
+
self.assertEqual(a, b)
|
58
|
+
self.assertNotEqual(a, c)
|
@@ -1,43 +0,0 @@
|
|
1
|
-
from abc import ABC, abstractmethod
|
2
|
-
|
3
|
-
class IStdClass(ABC):
|
4
|
-
"""
|
5
|
-
Interface for a dynamic class that allows setting arbitrary attributes,
|
6
|
-
similar to PHP's stdClass.
|
7
|
-
"""
|
8
|
-
|
9
|
-
@abstractmethod
|
10
|
-
def __repr__(self) -> str:
|
11
|
-
"""
|
12
|
-
Returns a string representation of the object.
|
13
|
-
|
14
|
-
Returns
|
15
|
-
-------
|
16
|
-
str
|
17
|
-
A formatted string showing the object's attributes.
|
18
|
-
"""
|
19
|
-
pass
|
20
|
-
|
21
|
-
@abstractmethod
|
22
|
-
def toDict(self) -> dict:
|
23
|
-
"""
|
24
|
-
Converts the object's attributes to a dictionary.
|
25
|
-
|
26
|
-
Returns
|
27
|
-
-------
|
28
|
-
dict
|
29
|
-
A dictionary representation of the object's attributes.
|
30
|
-
"""
|
31
|
-
pass
|
32
|
-
|
33
|
-
@abstractmethod
|
34
|
-
def update(self, **kwargs):
|
35
|
-
"""
|
36
|
-
Updates the object's attributes dynamically.
|
37
|
-
|
38
|
-
Parameters
|
39
|
-
----------
|
40
|
-
kwargs : dict
|
41
|
-
Key-value pairs to update attributes.
|
42
|
-
"""
|
43
|
-
pass
|
@@ -1,47 +0,0 @@
|
|
1
|
-
import traceback
|
2
|
-
from orionis.luminate.contracts.support.exception_parse import IExceptionParse
|
3
|
-
|
4
|
-
class ExceptionParse(IExceptionParse):
|
5
|
-
"""
|
6
|
-
A utility class to parse an exception and convert it into a structured dictionary.
|
7
|
-
"""
|
8
|
-
|
9
|
-
@staticmethod
|
10
|
-
def toDict(exception):
|
11
|
-
"""
|
12
|
-
Parse the provided exception and serialize it into a dictionary format.
|
13
|
-
|
14
|
-
Parameters
|
15
|
-
----------
|
16
|
-
exception : Exception
|
17
|
-
The exception object to be serialized.
|
18
|
-
|
19
|
-
Returns
|
20
|
-
-------
|
21
|
-
dict
|
22
|
-
A dictionary containing the exception details such as error type, message,
|
23
|
-
and the stack trace.
|
24
|
-
|
25
|
-
Notes
|
26
|
-
-----
|
27
|
-
- Uses `traceback.TracebackException.from_exception()` to extract detailed traceback information.
|
28
|
-
- The stack trace includes filenames, line numbers, function names, and the exact line of code.
|
29
|
-
"""
|
30
|
-
# Extract the detailed traceback information from the exception
|
31
|
-
tb = traceback.TracebackException.from_exception(exception)
|
32
|
-
|
33
|
-
# Construct and return the dictionary containing all necessary exception details
|
34
|
-
return {
|
35
|
-
"error_type": tb.exc_type_str,
|
36
|
-
"error_message": str(tb).strip(),
|
37
|
-
"error_code": getattr(exception, "code", None),
|
38
|
-
"stack_trace": [
|
39
|
-
{
|
40
|
-
"filename": frame.filename,
|
41
|
-
"lineno": frame.lineno,
|
42
|
-
"name": frame.name,
|
43
|
-
"line": frame.line
|
44
|
-
}
|
45
|
-
for frame in tb.stack
|
46
|
-
]
|
47
|
-
}
|