orionis 0.30.0__py3-none-any.whl → 0.34.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.30.0"
8
+ VERSION = "0.34.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
orionis/luminate/app.py CHANGED
@@ -1,36 +1,26 @@
1
1
  from orionis.luminate.container.container import Container
2
+ from orionis.luminate.cache.app.config import CacheConfig
3
+ from orionis.luminate.bootstrap.config.register import Register
4
+ from orionis.luminate.bootstrap.config.bootstrapper import Bootstrapper
5
+ from orionis.luminate.patterns.singleton import SingletonMeta
2
6
 
3
- class App:
7
+ class App(metaclass=SingletonMeta):
4
8
 
5
9
  def __init__(self):
6
- # Inicializa el contenedor de dependencias
7
10
  self.container = Container()
8
11
 
9
12
  def start(self):
10
- pass
13
+ self._register_config_providers()
14
+ self._resolve_config_providers()
11
15
 
12
16
  def finish(self):
13
- pass
17
+ self.container = None
14
18
 
15
- def in_context(self):
16
- """Método placeholder para gestionar el contexto de la aplicación"""
17
- pass
19
+ def _register_config_providers(self):
20
+ self.container.singleton(CacheConfig)
21
+ self.container.singleton(Register)
22
+ self.container.singleton(Bootstrapper)
18
23
 
19
- def register_service_providers(self):
20
- """
21
- Registra los proveedores de servicios en el contenedor.
22
- Carga y registra los servicios de forma perezosa.
23
- """
24
- # Importación perezosa de los servicios
25
- from orionis.luminate.cache.app.config import CacheConfig
26
- from orionis.luminate.bootstrap.config.register import Register
27
- from orionis.luminate.bootstrap.config.bootstrapper import Bootstrapper
28
-
29
- # Registro de servicios esenciales en el contenedor
30
- self.container.singleton(CacheConfig) # Configuración del cache
31
- self.container.singleton(Register) # Registro de la configuración de la app
32
- self.container.singleton(Bootstrapper) # Inicialización del sistema
33
-
34
- def load_config(self):
35
- """Método placeholder para cargar la configuración de la aplicación"""
36
- pass
24
+ def _resolve_config_providers(self):
25
+ self.container.make(Register)
26
+ self.container.make(Bootstrapper)
@@ -442,15 +442,17 @@ class Console(IConsole):
442
442
  """
443
443
 
444
444
  errors = ExceptionsToDict.parse(e)
445
- error_type = errors.get("error_type")
446
- error_message = errors.get("error_message")
445
+ error_type = errors.get("error_type").split(".")[-1]
446
+ error_message = errors.get("error_message").replace(error_type, "").replace("[]", "").strip()
447
447
  stack_trace = errors.get("stack_trace")
448
448
 
449
449
  # Format the output with a more eye-catching appearance
450
- message = f"{ANSIColors.BG_ERROR.value}{ANSIColors.TEXT_WHITE.value} [{error_type}] {ANSIColors.TEXT_RESET.value}: {ANSIColors.TEXT_WARNING.value}{error_message}{ANSIColors.TEXT_RESET.value}"
451
- print("-" * len(f" [{error_type}] : {error_message}")) # separator line
450
+ message = f"{ANSIColors.BG_ERROR.value}{ANSIColors.TEXT_WHITE.value}[{error_type}]{ANSIColors.TEXT_RESET.value}: {ANSIColors.TEXT_WARNING.value}{error_message}{ANSIColors.TEXT_RESET.value}"
451
+ print("" * len(f" [{error_type}] : {error_message}"))
452
452
  print(message)
453
453
 
454
+ real_count = len(stack_trace)
455
+ count_error = real_count
454
456
  for frame in stack_trace:
455
457
  filename = frame["filename"]
456
458
  lineno = frame["lineno"]
@@ -458,6 +460,8 @@ class Console(IConsole):
458
460
  line = frame["line"]
459
461
 
460
462
  # Print the stack trace with enhanced styling
461
- print(f"{ANSIColors.CYAN.value}{ANSIColors.DIM.value} {ANSIColors.MAGENTA.value}{ANSIColors.TEXT_BOLD.value}{filename}:{ANSIColors.TEXT_BOLD.value}{lineno}{ANSIColors.TEXT_RESET.value} / {ANSIColors.DIM.value}{ANSIColors.ITALIC.value}{ANSIColors.TEXT_WARNING.value}{name}{ANSIColors.TEXT_RESET.value} / {ANSIColors.CYAN.value}{line}{ANSIColors.TEXT_RESET.value}")
463
+ print(f"{ANSIColors.TEXT_MUTED.value}Trace Call ({count_error}/{real_count}){ANSIColors.TEXT_RESET.value} - {ANSIColors.TEXT_WHITE.value}{filename}:{lineno}{ANSIColors.TEXT_RESET.value}")
464
+ print(f" {ANSIColors.DIM.value}{ANSIColors.ITALIC.value}{ANSIColors.TEXT_WARNING.value}{name}{ANSIColors.TEXT_RESET.value} : {ANSIColors.CYAN.value}{line}{ANSIColors.TEXT_RESET.value}")
465
+ count_error -= 1
462
466
 
463
- print("-" * len(f" [{error_type}] : {error_message}"))
467
+ print("" * len(f" [{error_type}] : {error_message}"))
@@ -5,6 +5,7 @@ from typing import Callable, Any, Dict
5
5
  from orionis.luminate.container.exception import OrionisContainerException, OrionisContainerValueError, OrionisContainerTypeError
6
6
  from orionis.luminate.container.types import Types
7
7
  from orionis.luminate.contracts.container.container_interface import IContainer
8
+ from orionis.luminate.patterns.singleton import SingletonMeta
8
9
 
9
10
  BINDING = 'binding'
10
11
  TRANSIENT = 'transient'
@@ -12,7 +13,7 @@ SINGLETON = 'singleton'
12
13
  SCOPED = 'scoped'
13
14
  INSTANCE = 'instance'
14
15
 
15
- class Container(IContainer):
16
+ class Container(IContainer, metaclass=SingletonMeta):
16
17
  """
17
18
  Service container and dependency injection manager.
18
19
 
@@ -20,23 +21,15 @@ class Container(IContainer):
20
21
  and different lifecycle types such as transient, singleton, and scoped.
21
22
  """
22
23
 
23
- _instance = None
24
- _lock = Lock()
25
-
26
- def __new__(cls):
27
- if cls._instance is None:
28
- with cls._lock:
29
- if cls._instance is None:
30
- cls._instance = super().__new__(cls)
31
- cls._instance._bindings = {}
32
- cls._instance._transients = {}
33
- cls._instance._singletons = {}
34
- cls._instance._scoped_services = {}
35
- cls._instance._instances = {}
36
- cls._instance._aliases = {}
37
- cls._instance._scoped_instances = {}
38
- cls._instance._validate_types = Types()
39
- return cls._instance
24
+ def __init__(self):
25
+ self._bindings = {}
26
+ self._transients = {}
27
+ self._singletons = {}
28
+ self._scoped_services = {}
29
+ self._instances = {}
30
+ self._aliases = {}
31
+ self._scoped_instances = {}
32
+ self._validate_types = Types()
40
33
 
41
34
  def _newRequest(self) -> None:
42
35
  """
@@ -312,7 +305,17 @@ class Container(IContainer):
312
305
  OrionisContainerException
313
306
  If the service is not found in the container.
314
307
  """
315
- key = self._aliases.get(abstract, abstract)
308
+
309
+ key = abstract
310
+
311
+ if isinstance(abstract, str):
312
+ key = self._aliases.get(key, key)
313
+
314
+ if callable(abstract):
315
+ key = f"{abstract.__module__}.{abstract.__name__}"
316
+
317
+ if isinstance(abstract, object) and abstract.__class__.__module__ not in {'builtins', 'abc'}:
318
+ key = f"{abstract.__class__.__module__}.{abstract.__class__.__name__}"
316
319
 
317
320
  if key in self._instances:
318
321
  return self._instances[key]['instance']
@@ -1,7 +1,8 @@
1
1
  import traceback
2
2
  from orionis.luminate.app import App
3
+ from orionis.luminate.patterns.singleton import SingletonMeta
3
4
 
4
- class OrionisContext:
5
+ class Orionis(metaclass=SingletonMeta):
5
6
  """
6
7
  Context manager for the Orionis application that handles startup and cleanup.
7
8
 
@@ -87,7 +88,7 @@ class OrionisContext:
87
88
  self.error_info = (exc_val, traceback.format_exc())
88
89
  return False
89
90
 
90
- def is_active(self):
91
+ def isStarted(self):
91
92
  """
92
93
  Check if the application is currently active.
93
94
 
@@ -98,7 +99,7 @@ class OrionisContext:
98
99
  """
99
100
  return self.is_started
100
101
 
101
- def get_error(self):
102
+ def getError(self):
102
103
  """
103
104
  Retrieve the stored error information.
104
105
 
@@ -0,0 +1,44 @@
1
+ import threading
2
+
3
+ class SingletonMeta(type):
4
+ """
5
+ A thread-safe metaclass for implementing the Singleton pattern.
6
+
7
+ This metaclass ensures that only one instance of a class is created,
8
+ even in a multithreaded environment, by using a lock to synchronize
9
+ instance creation.
10
+
11
+ Attributes
12
+ ----------
13
+ _instances : dict
14
+ A dictionary that holds the single instances of the classes using this metaclass.
15
+ _lock : threading.Lock
16
+ A lock to ensure thread-safe instance creation.
17
+ """
18
+ _instances = {}
19
+ _lock = threading.Lock()
20
+
21
+ def __call__(cls, *args, **kwargs):
22
+ """
23
+ Return the singleton instance of the class in a thread-safe manner.
24
+
25
+ If an instance does not already exist, it is created under the protection
26
+ of a lock; otherwise, the existing instance is returned.
27
+
28
+ Parameters
29
+ ----------
30
+ *args : list
31
+ Positional arguments for the class constructor.
32
+ **kwargs : dict
33
+ Keyword arguments for the class constructor.
34
+
35
+ Returns
36
+ -------
37
+ object
38
+ The singleton instance of the class.
39
+ """
40
+ if cls not in cls._instances:
41
+ with cls._lock:
42
+ if cls not in cls._instances:
43
+ cls._instances[cls] = super().__call__(*args, **kwargs)
44
+ return cls._instances[cls]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.30.0
3
+ Version: 0.34.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,9 +1,9 @@
1
1
  orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  orionis/cli_manager.py,sha256=9wNVJxB0HyqUbNesUvkwlsqTyUbZwK6R46iVLE5WVBQ,1715
3
- orionis/framework.py,sha256=xtmJazlCIPVp_r-jU-eWaI19VnVIrsyHVtGbaEm1o2o,1386
3
+ orionis/framework.py,sha256=lievfimHcqj63V6oBF1kmjmPa9BXOfh5FGYVnhzjS6M,1386
4
4
  orionis/luminate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- orionis/luminate/app.py,sha256=4exLRx5qKyHz9aeb0DCZMcbUe0gDGuKP5lt2AfkrB10,1290
6
- orionis/luminate/orionis.py,sha256=VM6YgIBZBu6WU7Tv5i22wbuIhWVJsDrtDxokBP169o8,3512
5
+ orionis/luminate/app.py,sha256=d_p--jxfOMbO2inEwWVTQONJxLKan0OaC5tOFu4SRg8,899
6
+ orionis/luminate/orionis.py,sha256=qIuXGlM1lvoOAF0kLzoukk3aY3h-Etr1stbKEWqnUpY,3592
7
7
  orionis/luminate/bootstrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  orionis/luminate/bootstrap/cli_exception.py,sha256=wDKfEW295c7-bavr7YUHK2CLYcTSZgjT9ZRSBne6GOE,1356
9
9
  orionis/luminate/bootstrap/commands/bootstrapper.py,sha256=TuXuQUzeaiDL8sJyZNdqnFl2h2MfxcnSU045IeIKVQE,4016
@@ -48,7 +48,7 @@ orionis/luminate/console/commands/version.py,sha256=oM5Vr_2Xc7Eaq6VHbcMaTeteY0cD
48
48
  orionis/luminate/console/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  orionis/luminate/console/exceptions/cli_exception.py,sha256=QM7tRdPBoo7WdmAb3Zasj8d3429zskftUGYHAvhcnSU,4631
50
50
  orionis/luminate/console/output/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
- orionis/luminate/console/output/console.py,sha256=61rMbYQHmQxzt2cZdX9Sz6y9TidqDiDfrPFXghky8Rg,16178
51
+ orionis/luminate/console/output/console.py,sha256=15MC5NnSli8J27aIoZZfNrqC3fSCAE6DCfnu8coXCqY,16353
52
52
  orionis/luminate/console/output/executor.py,sha256=J4lmWMRCXW2b5L8PbX31q1fGnnjYZOO93O4rtPyA_0A,3379
53
53
  orionis/luminate/console/output/progress_bar.py,sha256=YT8Gl-_Zfc3E6foU-Dw7aAndZm4m-xY36G3MpPi3Aj4,3106
54
54
  orionis/luminate/console/output/styles.py,sha256=2e1_FJdNpKaVqmdlCx-udzTleH_6uEFE9_TjH7T1ZUk,3696
@@ -56,7 +56,7 @@ orionis/luminate/console/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
56
56
  orionis/luminate/console/scripts/management.py,sha256=J5gLXtvX8I1zdNk6sa23njR18D5s4LJXZK7ElK0sFzI,2868
57
57
  orionis/luminate/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
58
  orionis/luminate/console/tasks/scheduler.py,sha256=CUmv9ap7zq3IWVTPtpPBZ-x166jsj1e0lTvw3didUQM,22692
59
- orionis/luminate/container/container.py,sha256=GMUsyKmlqzmsjJeMTYlwOzleEBWzTqlEyX-jLtZu9M8,16069
59
+ orionis/luminate/container/container.py,sha256=NcwlVswd_fbj9WUGVufS7HqBO06vJ6r1_MTaKDyI2VA,16100
60
60
  orionis/luminate/container/exception.py,sha256=ap1SqYEjQEEHXJJTNmL7V1jrmRjgT5_7geZ95MYkhMA,1691
61
61
  orionis/luminate/container/types.py,sha256=PbPNOJ8e4SGzCmu-zOmCQmDzt1b9I73v3fw_xzLq9RU,932
62
62
  orionis/luminate/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -123,6 +123,7 @@ orionis/luminate/installer/setup.py,sha256=1hpU4nO2e2AeHb9hNYyvhruiYk9fHVNNc5OSp
123
123
  orionis/luminate/installer/upgrade.py,sha256=kJT6p2j_2nHNihlSBIm--fL-yQpqX8MtOdmuaqAmkVM,1421
124
124
  orionis/luminate/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
125
125
  orionis/luminate/log/logger.py,sha256=9s_zYIa7b388WRlDl1WdMW_lzIEsBOROA2YlWq_C02E,3651
126
+ orionis/luminate/patterns/singleton.py,sha256=b3U0nubKSQWyal5wTXADVPtOztkaTk-M8Zwy-bje1L0,1425
126
127
  orionis/luminate/pipelines/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
127
128
  orionis/luminate/pipelines/cli_pipeline.py,sha256=UpEWClNSxeDnFEpryrBSQZ6z2SFpXrW0GazEQ6ejoEM,3809
128
129
  orionis/luminate/publisher/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -146,9 +147,9 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
146
147
  tests/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
147
148
  tests/tools/class_example.py,sha256=dIPD997Y15n6WmKhWoOFSwEldRm9MdOHTZZ49eF1p3c,1056
148
149
  tests/tools/test_reflection.py,sha256=dNN5p_xAosyEf0ddAElmmmTfhcTtBd4zBNl7qzgnsc0,5242
149
- orionis-0.30.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
150
- orionis-0.30.0.dist-info/METADATA,sha256=PsyKM0V1nld_HPgnrK97KGWIBmxLNxuizjJaMfTeFWc,2978
151
- orionis-0.30.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
152
- orionis-0.30.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
153
- orionis-0.30.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
154
- orionis-0.30.0.dist-info/RECORD,,
150
+ orionis-0.34.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
151
+ orionis-0.34.0.dist-info/METADATA,sha256=73kpkJv6oLnEREnoDXJTYBo9RN9y0GmrVT-rJPrW1yM,2978
152
+ orionis-0.34.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
153
+ orionis-0.34.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
154
+ orionis-0.34.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
155
+ orionis-0.34.0.dist-info/RECORD,,