orionis 0.319.0__py3-none-any.whl → 0.321.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/container/container.py +138 -739
- orionis/container/contracts/container.py +61 -15
- orionis/container/resolver.py +404 -0
- orionis/container/validators/__init__.py +0 -0
- orionis/container/validators/implements.py +67 -0
- orionis/container/validators/is_abstract_class.py +34 -0
- orionis/container/validators/is_callable.py +30 -0
- orionis/container/validators/is_concrete_class.py +34 -0
- orionis/container/validators/is_instance.py +32 -0
- orionis/container/validators/is_not_subclass.py +32 -0
- orionis/container/validators/is_subclass.py +32 -0
- orionis/container/validators/is_valid_alias.py +37 -0
- orionis/container/validators/lifetime.py +53 -0
- orionis/metadata/framework.py +1 -1
- {orionis-0.319.0.dist-info → orionis-0.321.0.dist-info}/METADATA +1 -1
- {orionis-0.319.0.dist-info → orionis-0.321.0.dist-info}/RECORD +20 -9
- {orionis-0.319.0.dist-info → orionis-0.321.0.dist-info}/WHEEL +0 -0
- {orionis-0.319.0.dist-info → orionis-0.321.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.319.0.dist-info → orionis-0.321.0.dist-info}/top_level.txt +0 -0
- {orionis-0.319.0.dist-info → orionis-0.321.0.dist-info}/zip-safe +0 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from orionis.container.exceptions.type_error_exception import OrionisContainerTypeError
|
3
|
+
|
4
|
+
class _IsCallable:
|
5
|
+
"""
|
6
|
+
Validator that checks if a value is callable.
|
7
|
+
Can be used directly like a function: `IsCallable(value)`
|
8
|
+
"""
|
9
|
+
|
10
|
+
def __call__(self, value: Any) -> None:
|
11
|
+
"""
|
12
|
+
Ensures that the provided value is callable.
|
13
|
+
|
14
|
+
Parameters
|
15
|
+
----------
|
16
|
+
value : Any
|
17
|
+
The value to check.
|
18
|
+
|
19
|
+
Raises
|
20
|
+
------
|
21
|
+
OrionisContainerTypeError
|
22
|
+
If the value is not callable.
|
23
|
+
"""
|
24
|
+
if not callable(value):
|
25
|
+
raise OrionisContainerTypeError(
|
26
|
+
f"Expected a callable type, but got {type(value).__name__} instead."
|
27
|
+
)
|
28
|
+
|
29
|
+
# Exported singleton instance
|
30
|
+
IsCallable = _IsCallable()
|
@@ -0,0 +1,34 @@
|
|
1
|
+
from typing import Callable, Any
|
2
|
+
from orionis.services.introspection.concretes.reflection_concrete import ReflectionConcrete
|
3
|
+
from orionis.container.exceptions.type_error_exception import OrionisContainerTypeError
|
4
|
+
|
5
|
+
class _IsConcreteClass:
|
6
|
+
"""
|
7
|
+
Validator that ensures a class is a concrete (non-abstract) class.
|
8
|
+
"""
|
9
|
+
|
10
|
+
def __call__(self, concrete: Callable[..., Any], lifetime: str) -> None:
|
11
|
+
"""
|
12
|
+
Ensures that the provided class is a concrete (non-abstract) class.
|
13
|
+
|
14
|
+
Parameters
|
15
|
+
----------
|
16
|
+
concrete : Callable[..., Any]
|
17
|
+
The class intended to represent the concrete implementation.
|
18
|
+
lifetime : str
|
19
|
+
A string indicating the service lifetime, used in error messages.
|
20
|
+
|
21
|
+
Raises
|
22
|
+
------
|
23
|
+
OrionisContainerTypeError
|
24
|
+
If the class is abstract or invalid.
|
25
|
+
"""
|
26
|
+
try:
|
27
|
+
ReflectionConcrete.ensureIsConcreteClass(concrete)
|
28
|
+
except Exception as e:
|
29
|
+
raise OrionisContainerTypeError(
|
30
|
+
f"Unexpected error registering {lifetime} service: {e}"
|
31
|
+
) from e
|
32
|
+
|
33
|
+
# Exported singleton instance
|
34
|
+
IsConcreteClass = _IsConcreteClass()
|
@@ -0,0 +1,32 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from orionis.services.introspection.instances.reflection_instance import ReflectionInstance
|
3
|
+
from orionis.container.exceptions.type_error_exception import OrionisContainerTypeError
|
4
|
+
|
5
|
+
class _IsInstance:
|
6
|
+
"""
|
7
|
+
Validator that ensures the provided object is a valid instance (not a class or abstract type).
|
8
|
+
"""
|
9
|
+
|
10
|
+
def __call__(self, instance: Any) -> None:
|
11
|
+
"""
|
12
|
+
Ensures that the provided object is a valid instance.
|
13
|
+
|
14
|
+
Parameters
|
15
|
+
----------
|
16
|
+
instance : Any
|
17
|
+
The object to be validated.
|
18
|
+
|
19
|
+
Raises
|
20
|
+
------
|
21
|
+
OrionisContainerTypeError
|
22
|
+
If the object is not a valid instance.
|
23
|
+
"""
|
24
|
+
try:
|
25
|
+
ReflectionInstance.ensureIsInstance(instance)
|
26
|
+
except Exception as e:
|
27
|
+
raise OrionisContainerTypeError(
|
28
|
+
f"Error registering instance: {e}"
|
29
|
+
) from e
|
30
|
+
|
31
|
+
# Exported singleton instance
|
32
|
+
IsInstance = _IsInstance()
|
@@ -0,0 +1,32 @@
|
|
1
|
+
from typing import Callable
|
2
|
+
from orionis.container.exceptions.container_exception import OrionisContainerException
|
3
|
+
|
4
|
+
class _IsNotSubclass:
|
5
|
+
"""
|
6
|
+
Validator that ensures a class is NOT a subclass of another class.
|
7
|
+
"""
|
8
|
+
|
9
|
+
def __call__(self, abstract: Callable[..., any], concrete: Callable[..., any]) -> None:
|
10
|
+
"""
|
11
|
+
Validates that the concrete class is NOT a subclass of the abstract class.
|
12
|
+
|
13
|
+
Parameters
|
14
|
+
----------
|
15
|
+
abstract : Callable[..., Any]
|
16
|
+
The supposed base class or interface.
|
17
|
+
concrete : Callable[..., Any]
|
18
|
+
The implementation class to check.
|
19
|
+
|
20
|
+
Raises
|
21
|
+
------
|
22
|
+
OrionisContainerException
|
23
|
+
If the concrete class IS a subclass of the abstract class.
|
24
|
+
"""
|
25
|
+
if issubclass(concrete, abstract):
|
26
|
+
raise OrionisContainerException(
|
27
|
+
"The concrete class must NOT inherit from the provided abstract class. "
|
28
|
+
"Please ensure that the concrete class is not a subclass of the specified abstract class."
|
29
|
+
)
|
30
|
+
|
31
|
+
# Exported singleton instance
|
32
|
+
IsNotSubclass = _IsNotSubclass()
|
@@ -0,0 +1,32 @@
|
|
1
|
+
from typing import Callable
|
2
|
+
from orionis.container.exceptions.container_exception import OrionisContainerException
|
3
|
+
|
4
|
+
class _IsSubclass:
|
5
|
+
"""
|
6
|
+
Validator that ensures a class is a subclass of a given abstract class.
|
7
|
+
"""
|
8
|
+
|
9
|
+
def __call__(self, abstract: Callable[..., any], concrete: Callable[..., any]) -> None:
|
10
|
+
"""
|
11
|
+
Validates that the concrete class is a subclass of the abstract class.
|
12
|
+
|
13
|
+
Parameters
|
14
|
+
----------
|
15
|
+
abstract : Callable[..., Any]
|
16
|
+
The base or abstract class.
|
17
|
+
concrete : Callable[..., Any]
|
18
|
+
The class to verify.
|
19
|
+
|
20
|
+
Raises
|
21
|
+
------
|
22
|
+
OrionisContainerException
|
23
|
+
If the concrete class is NOT a subclass of the abstract class.
|
24
|
+
"""
|
25
|
+
if not issubclass(concrete, abstract):
|
26
|
+
raise OrionisContainerException(
|
27
|
+
"The concrete class must inherit from the provided abstract class. "
|
28
|
+
"Please ensure that the concrete class is a subclass of the specified abstract class."
|
29
|
+
)
|
30
|
+
|
31
|
+
# Exported singleton instance
|
32
|
+
IsSubclass = _IsSubclass()
|
@@ -0,0 +1,37 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from orionis.container.exceptions.type_error_exception import OrionisContainerTypeError
|
3
|
+
|
4
|
+
class _IsValidAlias:
|
5
|
+
"""
|
6
|
+
Validator that checks if a value is a valid alias string.
|
7
|
+
"""
|
8
|
+
|
9
|
+
_INVALID_CHARS = set(' \t\n\r\x0b\x0c!@#$%^&*()[]{};:,/<>?\\|`~"\'')
|
10
|
+
|
11
|
+
def __call__(self, value: Any) -> None:
|
12
|
+
"""
|
13
|
+
Ensures that the provided value is a valid alias of type str and does not contain invalid characters.
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
----------
|
17
|
+
value : Any
|
18
|
+
The value to check.
|
19
|
+
|
20
|
+
Raises
|
21
|
+
------
|
22
|
+
OrionisContainerTypeError
|
23
|
+
If the value is not of type str or contains invalid characters.
|
24
|
+
"""
|
25
|
+
if not isinstance(value, str):
|
26
|
+
raise OrionisContainerTypeError(
|
27
|
+
f"Expected a string type for alias, but got {type(value).__name__} instead."
|
28
|
+
)
|
29
|
+
|
30
|
+
if any(char in self._INVALID_CHARS for char in value):
|
31
|
+
raise OrionisContainerTypeError(
|
32
|
+
f"Alias '{value}' contains invalid characters. "
|
33
|
+
"Aliases must not contain whitespace or special symbols."
|
34
|
+
)
|
35
|
+
|
36
|
+
# Exported singleton instance
|
37
|
+
IsValidAlias = _IsValidAlias()
|
@@ -0,0 +1,53 @@
|
|
1
|
+
from typing import Any, Union
|
2
|
+
from orionis.container.enums.lifetimes import Lifetime
|
3
|
+
from orionis.container.exceptions.type_error_exception import OrionisContainerTypeError
|
4
|
+
|
5
|
+
class __LifetimeValidator:
|
6
|
+
"""
|
7
|
+
Validator that checks if a value is a valid lifetime and converts string representations
|
8
|
+
to Lifetime enum values.
|
9
|
+
"""
|
10
|
+
|
11
|
+
def __call__(self, lifetime: Union[str, Lifetime, Any]) -> Lifetime:
|
12
|
+
"""
|
13
|
+
Validates and normalizes the provided lifetime value.
|
14
|
+
|
15
|
+
Parameters
|
16
|
+
----------
|
17
|
+
lifetime : Union[str, Lifetime, Any]
|
18
|
+
The lifetime value to validate. Can be a Lifetime enum or a string
|
19
|
+
representing a valid lifetime.
|
20
|
+
|
21
|
+
Returns
|
22
|
+
-------
|
23
|
+
Lifetime
|
24
|
+
The validated Lifetime enum value.
|
25
|
+
|
26
|
+
Raises
|
27
|
+
------
|
28
|
+
OrionisContainerTypeError
|
29
|
+
If the value is not a valid Lifetime enum or string representation,
|
30
|
+
or if the string doesn't match any valid Lifetime value.
|
31
|
+
"""
|
32
|
+
# Already a Lifetime enum
|
33
|
+
if isinstance(lifetime, Lifetime):
|
34
|
+
return lifetime
|
35
|
+
|
36
|
+
# String that might represent a Lifetime
|
37
|
+
if isinstance(lifetime, str):
|
38
|
+
lifetime_key = lifetime.strip().upper()
|
39
|
+
if lifetime_key in Lifetime.__members__:
|
40
|
+
return Lifetime[lifetime_key]
|
41
|
+
|
42
|
+
valid_options = ', '.join(Lifetime.__members__.keys())
|
43
|
+
raise OrionisContainerTypeError(
|
44
|
+
f"Invalid lifetime '{lifetime}'. Valid options are: {valid_options}."
|
45
|
+
)
|
46
|
+
|
47
|
+
# Invalid type
|
48
|
+
raise OrionisContainerTypeError(
|
49
|
+
f"Lifetime must be of type str or Lifetime enum, got {type(lifetime).__name__}."
|
50
|
+
)
|
51
|
+
|
52
|
+
# Exported singleton instance
|
53
|
+
LifetimeValidator = __LifetimeValidator()
|
orionis/metadata/framework.py
CHANGED
@@ -135,13 +135,24 @@ orionis/console/output/console.py,sha256=TE_Hl720ADd82dbERFSWhkoQRukDQZmETSw4nkw
|
|
135
135
|
orionis/console/output/executor.py,sha256=bdvkzW2-buy0BPpy2r5qUGrRFW2Ay6k-5rSeHb0gQ3o,3352
|
136
136
|
orionis/console/output/progress_bar.py,sha256=vFy582z6VJS46LV6tuyrmr9qvdVeTEtw3hyNcEHezeg,3088
|
137
137
|
orionis/console/output/styles.py,sha256=6a4oQCOBOKMh2ARdeq5GlIskJ3wjiylYmh66tUKKmpQ,4053
|
138
|
-
orionis/container/container.py,sha256=
|
139
|
-
orionis/container/
|
138
|
+
orionis/container/container.py,sha256=eBVQMzfSvXcxrdm-0hq0gmXZzxf3uabIcxbGVvGZmIo,22342
|
139
|
+
orionis/container/resolver.py,sha256=iuyTWCnCqWXQCtWvFXPdS9cR_g3Q58_wjHVn0Yg0YNM,16209
|
140
|
+
orionis/container/contracts/container.py,sha256=ksMn6ZLnFkIxd9_hbUGz3OpHzaYTA5izcDtH959kOow,7603
|
140
141
|
orionis/container/entities/binding.py,sha256=Qp6Lf4XUDp2NjqXDAC2lzvhOFQWiBDKiGFcKfwb4axw,4342
|
141
142
|
orionis/container/enums/lifetimes.py,sha256=RqQmugMIB1Ev_j_vFLcWorndm-to7xg4stQ7yKFDdDw,190
|
142
143
|
orionis/container/exceptions/container_exception.py,sha256=goTDEwC70xTMD2qppN8KV-xyR0Nps218OD4D1LZ2-3s,470
|
143
144
|
orionis/container/exceptions/type_error_exception.py,sha256=cYuvoXVOgRYj3tZPfK341aUERkf33-buOiI2eXxcrAw,470
|
144
145
|
orionis/container/exceptions/value_exception.py,sha256=hjY0YEusoL3DurME1ornxvIv1wyGaf6tBggLFlGHblo,472
|
146
|
+
orionis/container/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
147
|
+
orionis/container/validators/implements.py,sha256=iSoDxxTalQKhyKjvsojFlkROhBFvAjvJxRvPJlmGrSg,2843
|
148
|
+
orionis/container/validators/is_abstract_class.py,sha256=Q-Lqyrrps6oj2XWI0KFRp-hDZf4_sgbZlEbfBXj5XT4,1169
|
149
|
+
orionis/container/validators/is_callable.py,sha256=8Bi5AflNmXhpgtk1ieirE3xgCKzq3mcgyqokCU3GHN8,843
|
150
|
+
orionis/container/validators/is_concrete_class.py,sha256=BMhJ7vCQ2ccBA3qrRJPlsYDTSqBpqLZFfrdEGO5mlr4,1215
|
151
|
+
orionis/container/validators/is_instance.py,sha256=vUwWIMeG1zLMsGX9GyoOU-LZtCgqBDZ9hUNDj_KyuYo,999
|
152
|
+
orionis/container/validators/is_not_subclass.py,sha256=-iZw5ZCYnQtlU-xPO-o7lUj5DxPkN0G67-bLbLVhwtw,1167
|
153
|
+
orionis/container/validators/is_subclass.py,sha256=O2aF0KLg5ZnDutKQ1xDvet34kentftlqgEkRNvumCoM,1135
|
154
|
+
orionis/container/validators/is_valid_alias.py,sha256=avm6uz-huVi_kRov4BksSToslIHQfz-MLynjkzhdSRM,1246
|
155
|
+
orionis/container/validators/lifetime.py,sha256=78o7BHBCRReG8vnF0gW2RUf6m6wwMhr7w4VA6F2B46A,1865
|
145
156
|
orionis/foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
146
157
|
orionis/foundation/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
147
158
|
orionis/foundation/config/startup.py,sha256=JKAH2ZRhlAZgkD2w11LR1-TVktfjSH9cHo3PsZXOLrg,8275
|
@@ -233,7 +244,7 @@ orionis/foundation/contracts/config.py,sha256=Rpz6U6t8OXHO9JJKSTnCimytXE-tfCB-1i
|
|
233
244
|
orionis/foundation/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
234
245
|
orionis/foundation/exceptions/integrity.py,sha256=mc4pL1UMoYRHEmphnpW2oGk5URhu7DJRREyzHaV-cs8,472
|
235
246
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
236
|
-
orionis/metadata/framework.py,sha256=
|
247
|
+
orionis/metadata/framework.py,sha256=gv-aVbvyQwRvOTPPCJTIwJffZOEd9Ak6L9jdwT46oOE,4960
|
237
248
|
orionis/metadata/package.py,sha256=tqLfBRo-w1j_GN4xvzUNFyweWYFS-qhSgAEc-AmCH1M,5452
|
238
249
|
orionis/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
239
250
|
orionis/patterns/singleton/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -345,7 +356,7 @@ orionis/test/suite/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
345
356
|
orionis/test/suite/test_unit.py,sha256=MWgW8dRCRyT1XZ5LsbXQ7-KVPReasoXwzEEL1EWWfE4,52190
|
346
357
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
347
358
|
orionis/test/view/render.py,sha256=jXZkbITBknbUwm_mD8bcTiwLDvsFkrO9qrf0ZgPwqxc,4903
|
348
|
-
orionis-0.
|
359
|
+
orionis-0.321.0.dist-info/licenses/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
349
360
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
350
361
|
tests/example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
351
362
|
tests/example/test_example.py,sha256=kvWgiW3ADEZf718dGsMPtDh_rmOSx1ypEInKm7_6ZPQ,601
|
@@ -446,8 +457,8 @@ tests/support/wrapper/test_services_wrapper_docdict.py,sha256=yeVwl-VcwkWSQYyxZu
|
|
446
457
|
tests/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
447
458
|
tests/testing/test_testing_result.py,sha256=MrGK3ZimedL0b5Ydu69Dg8Iul017AzLTm7VPxpXlpfU,4315
|
448
459
|
tests/testing/test_testing_unit.py,sha256=DjLBtvVn8B1KlVJNNkstBT8_csA1yeaMqnGrbanN_J4,7438
|
449
|
-
orionis-0.
|
450
|
-
orionis-0.
|
451
|
-
orionis-0.
|
452
|
-
orionis-0.
|
453
|
-
orionis-0.
|
460
|
+
orionis-0.321.0.dist-info/METADATA,sha256=kQ_DamwqrnAqkqPJQZd6mR4u-U_ERbRLwEw8FqTgTwE,4772
|
461
|
+
orionis-0.321.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
462
|
+
orionis-0.321.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
463
|
+
orionis-0.321.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
464
|
+
orionis-0.321.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|