orionis 0.68.0__py3-none-any.whl → 0.72.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.68.0"
8
+ VERSION = "0.72.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,33 +1,59 @@
1
- import json
2
1
  from orionis.luminate.container.container import Container
3
2
  from orionis.luminate.bootstrap.config_bootstrapper import ConfigBootstrapper
4
3
  from orionis.luminate.bootstrap.command_bootstrapper import CommandsBootstrapper
5
4
  from orionis.luminate.bootstrap.environment_bootstrapper import EnvironmentBootstrapper
6
5
  from orionis.luminate.patterns.singleton import SingletonMeta
6
+ from orionis.luminate.providers.environment.environment_provider import EnvironmentProvider
7
7
 
8
8
  class Application(metaclass=SingletonMeta):
9
9
 
10
- def __init__(self):
10
+ def __init__(self, container: Container):
11
11
 
12
+ # Atributos de la clase
12
13
  self._config = {}
13
14
  self._commands = {}
15
+ self._environment_vars = {}
14
16
 
15
- self.container = Container()
16
- self.container.instance(self.container)
17
+ # Inicializar el contenedor de la aplicacion
18
+ self.container = container
19
+ self.container.instance(container)
20
+
21
+ # Cargar el servidor de entorno
22
+ self._loadServiceProviderEnvironment()
23
+
24
+ # Cargar dinamicamente la configurcion de la aplicacion.
17
25
  self._bootstraping()
18
26
 
27
+ # Registrrar los comandos en el contenedor
28
+ self._registerCommands()
29
+
30
+ def _loadServiceProviderEnvironment(self):
31
+
32
+ # Cargar el proveedor de entorno
33
+ _environment_provider = EnvironmentProvider(app=self.container)
34
+ _environment_provider.register()
35
+ _environment_provider.boot()
36
+
19
37
  def _bootstraping(self):
38
+
39
+ # Cargar la configuracion de la aplicacion
20
40
  config_bootstrapper_key = self.container.singleton(ConfigBootstrapper)
21
41
  config_bootstrapper: ConfigBootstrapper = self.container.make(config_bootstrapper_key)
22
42
  self._config = config_bootstrapper.get()
23
43
 
44
+ # Cargar los comandos propios y definidos por el desarrollador
24
45
  commands_bootstrapper_key = self.container.singleton(CommandsBootstrapper)
25
46
  commands_bootstrapper: CommandsBootstrapper = self.container.make(commands_bootstrapper_key)
26
47
  self._commands = commands_bootstrapper.get()
27
48
 
49
+ # Cargar las variables de entorno solo desde el archivo .env (No se carga desde el sistema operativo, por seguridad)
28
50
  environment_bootstrapper_key = self.container.singleton(EnvironmentBootstrapper)
29
51
  environment_bootstrapper: EnvironmentBootstrapper = self.container.make(environment_bootstrapper_key)
30
- self._environment = environment_bootstrapper.get()
52
+ self._environment_vars = environment_bootstrapper.get()
53
+
54
+ def _registerCommands(self):
31
55
 
32
- def isBooted(self):
33
- return True
56
+ # Registrar los comandos en el contenedor
57
+ for command in self._commands:
58
+ _key_instance_container = self.container.bind(self._commands[command].get('concrete'))
59
+ self.container.alias(alias=command, concrete=_key_instance_container)
@@ -1,10 +1,7 @@
1
- import ast
2
- import os
3
- from pathlib import Path
4
1
  from typing import Dict
5
- from dotenv import dotenv_values
6
2
  from orionis.contracts.bootstrap.i_environment_bootstrapper import IEnvironmentBootstrapper
7
- from orionis.luminate.bootstrap.exception_bootstrapper import BootstrapRuntimeError
3
+ from orionis.luminate.facades.app import app
4
+ from orionis.luminate.services.environment.environment_service import EnvironmentService
8
5
 
9
6
  class EnvironmentBootstrapper(IEnvironmentBootstrapper):
10
7
  """
@@ -46,68 +43,9 @@ class EnvironmentBootstrapper(IEnvironmentBootstrapper):
46
43
  This method checks if the `.env` file exists in the current working directory.
47
44
  If the file does not exist, it creates an empty `.env` file. If the file exists,
48
45
  it loads the environment variables into the `_environment_vars` dictionary.
49
-
50
- Raises
51
- ------
52
- PermissionError
53
- If the `.env` file cannot be created or read due to insufficient permissions.
54
46
  """
55
- # Set the path to the `.env` file
56
- path: Path = Path(os.getcwd()) / ".env"
57
-
58
- # Create the `.env` file if it does not exist
59
- if not path.exists():
60
- try:
61
- path.touch() # Create an empty `.env` file if it does not exist
62
- except PermissionError as e:
63
- raise PermissionError(f"Cannot create `.env` file at {path}: {str(e)}")
64
-
65
- try:
66
- all_vars = dotenv_values(path)
67
- for key, value in all_vars.items():
68
- self._environment_vars[key] = self._parse_value(value)
69
- except Exception as e:
70
- raise BootstrapRuntimeError(f"Error loading environment variables from {path}: {str(e)}")
71
-
72
- def _parse_value(self, value):
73
- """
74
- Parse and convert a string value into its appropriate Python data type.
75
-
76
- This function handles conversion for common types such as `None`, booleans (`True`/`False`),
77
- integers, and Python literals (e.g., lists, dictionaries). If the value cannot be parsed
78
- into a specific type, it is returned as-is.
79
-
80
- Parameters
81
- ----------
82
- value : str or None
83
- The value to be parsed. If `None`, it is returned as `None`.
84
-
85
- Returns
86
- -------
87
- any
88
- The parsed value. Possible return types include:
89
- - `None` if the value is empty, `None`, `'None'`, or `'null'`.
90
- - `bool` if the value is `'True'`, `'true'`, `'False'`, or `'false'`.
91
- - `int` if the value is a digit string (e.g., `'123'`).
92
- - Python literals (e.g., lists, dictionaries) if the value can be evaluated as such.
93
- - The original value if no conversion is applicable.
94
- """
95
- # Strip leading and trailing whitespace from the value
96
- value = str(value).strip() if value is not None else None
97
-
98
- # Parse common types and Python literals
99
- if not value or value.lower() in {'none', 'null'}:
100
- return None
101
- if value.lower() in {'true', 'false'}:
102
- return value.lower() == 'true'
103
- if value.isdigit():
104
- return int(value)
105
-
106
- # Attempt to parse Python literals (e.g., lists, dictionaries)
107
- try:
108
- return ast.literal_eval(value)
109
- except (ValueError, SyntaxError):
110
- return value
47
+ environment_service : EnvironmentService = app(EnvironmentService)
48
+ self._environment_vars = environment_service.all()
111
49
 
112
50
  def get(self, key: str = None) -> str:
113
51
  """
@@ -248,13 +248,16 @@ class Container(IContainer):
248
248
  Raises:
249
249
  OrionisContainerException: If the concrete instance is not a valid object or if the alias is a primitive type.
250
250
  """
251
- if not callable(concrete) and not isinstance(concrete, object):
252
- raise OrionisContainerException(f"The instance '{str(concrete)}' must be a valid object.")
253
251
 
254
252
  if self._instance._validate_types.isPrimitive(alias):
255
253
  raise OrionisContainerException(f"Cannot use primitive type '{alias}' as an alias.")
256
254
 
257
- if isinstance(concrete, object) and concrete.__class__.__module__ not in ['builtins', 'abc']:
255
+ if isinstance(concrete, str):
256
+ if self.has(concrete):
257
+ current_key = concrete
258
+ else:
259
+ raise OrionisContainerException(f"Service '{concrete}' is not registered in the container.")
260
+ elif isinstance(concrete, object) and concrete.__class__.__module__ not in ['builtins', 'abc']:
258
261
  cls_concrete = concrete.__class__
259
262
  current_key = f"{cls_concrete.__module__}.{cls_concrete.__name__}"
260
263
  elif callable(concrete):
@@ -1,5 +1,7 @@
1
+ import ast
1
2
  import os
2
3
  from pathlib import Path
4
+ from typing import Any
3
5
  from dotenv import set_key, unset_key, dotenv_values
4
6
  from orionis.contracts.services.environment.i_environment_service import IEnvironmentService
5
7
 
@@ -51,11 +53,16 @@ class EnvironmentService(IEnvironmentService):
51
53
  str
52
54
  The value of the environment variable or the default value.
53
55
  """
56
+
54
57
  # Get the value from the .env file
55
58
  value = dotenv_values(self.path).get(key)
56
59
 
57
- # Return the value or the default value
58
- return value if value is not None else os.getenv(key, default)
60
+ # Get the value from the system environment variables if not found
61
+ if value is None:
62
+ value = os.getenv(key)
63
+
64
+ # Parse the value and return it
65
+ return self._parse_value(value) if value is not None else default
59
66
 
60
67
  def set(self, key: str, value: str) -> None:
61
68
  """
@@ -93,4 +100,32 @@ class EnvironmentService(IEnvironmentService):
93
100
  A dictionary of all environment variables and their values.
94
101
  """
95
102
  # Return all environment variables
96
- return dotenv_values(self.path)
103
+ env_vars = {}
104
+
105
+ # Get all environment variables from the .env file
106
+ data = dotenv_values(self.path)
107
+ for key, value in data.items():
108
+ # Parse the value and add it to the dictionary
109
+ env_vars[key] = self._parse_value(value)
110
+
111
+ # Get all environment variables from the system environment variables
112
+ return env_vars
113
+
114
+ def _parse_value(self, value : Any):
115
+
116
+ # Strip leading and trailing whitespace from the value
117
+ value = str(value).strip() if value is not None else None
118
+
119
+ # Parse common types and Python literals
120
+ if not value or value.lower() in {'none', 'null'}:
121
+ return None
122
+ if value.lower() in {'true', 'false'}:
123
+ return value.lower() == 'true'
124
+ if value.isdigit():
125
+ return int(value)
126
+
127
+ # Attempt to parse Python literals (e.g., lists, dictionaries)
128
+ try:
129
+ return ast.literal_eval(value)
130
+ except (ValueError, SyntaxError):
131
+ return value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.68.0
3
+ Version: 0.72.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/cli_manager.py,sha256=0bM-hABXJSoPGuvEgnqeaj9qcLP8VjTQ3z9Mb0TSEUI,1381
3
- orionis/framework.py,sha256=Bkfcg8Fns2s21OJxK0LzX2uCh_vQu-YjjxFAfgRme4s,1386
3
+ orionis/framework.py,sha256=qoKw9PXLHyVH-BLmh4czvAvZJgLFRSl8LNlap7VLELE,1386
4
4
  orionis/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  orionis/contracts/bootstrap/i_command_bootstrapper.py,sha256=cfpYWSlNhOY1q_C9o0H7F381OoM0Oh0qaeqP-c85nzk,2457
6
6
  orionis/contracts/bootstrap/i_config_bootstrapper.py,sha256=d2TXT74H2fCBbzWgrt9-ZG11S_H_YPQOEcJoIOrsgb0,4462
@@ -56,12 +56,12 @@ orionis/installer/installer_manager.py,sha256=Hb6T0bmSl39T30maY-nUWkrLhG77JdrKe4
56
56
  orionis/installer/installer_output.py,sha256=LeKxzuXpnHOKbKpUtx3tMGkCi2bGcPV1VNnfBxwfxUU,7161
57
57
  orionis/installer/installer_setup.py,sha256=c2HtVklSa-2_-YVonc7fwtoK-RTDqBS2Ybvbekgfqtc,6970
58
58
  orionis/luminate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
- orionis/luminate/app.py,sha256=RqhaFbBQH78t3IgSQc0FHrsSW414UDgee5e6Oy8JHEY,1446
59
+ orionis/luminate/app.py,sha256=MRB7235NLj2gKba1xqScpYiTs87nowllTIpVKXtOXVs,2682
60
60
  orionis/luminate/app_context.py,sha256=XREVkOHU6aP8UB2daA2QbFcOCB8HRmcGXjVbrlW1AHQ,1827
61
61
  orionis/luminate/bootstrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
62
  orionis/luminate/bootstrap/command_bootstrapper.py,sha256=OU0hDMtG1xqVbvCneq4C5mlOUu9OmfkxqbvGH59QsUw,6919
63
63
  orionis/luminate/bootstrap/config_bootstrapper.py,sha256=Gw83UtPAOggwzqmz062JfJcpIfmZvmIQyZJfgVFiIcQ,7474
64
- orionis/luminate/bootstrap/environment_bootstrapper.py,sha256=z8pbnT2oc_NDzqMtgsF6r_JWt5bvGFNenNb30HeRl2A,5219
64
+ orionis/luminate/bootstrap/environment_bootstrapper.py,sha256=GTZ-mBumoNlxYcqsQksw4XyH3TRfPkWAU62mB3wFKLk,2777
65
65
  orionis/luminate/bootstrap/exception_bootstrapper.py,sha256=wDKfEW295c7-bavr7YUHK2CLYcTSZgjT9ZRSBne6GOE,1356
66
66
  orionis/luminate/bootstrap/service_providers_bootstrapper.py,sha256=bQK1yDLP9dqks3TQhTaJDnrnla_79Tw8wTOY2AsLuDQ,268
67
67
  orionis/luminate/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -97,7 +97,7 @@ orionis/luminate/console/output/progress_bar.py,sha256=ssi8Drryr-shl7OxweTgGOhvR
97
97
  orionis/luminate/console/output/styles.py,sha256=2e1_FJdNpKaVqmdlCx-udzTleH_6uEFE9_TjH7T1ZUk,3696
98
98
  orionis/luminate/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
99
99
  orionis/luminate/console/tasks/scheduler.py,sha256=zt4p2VGUYGGrG2-E-MxyheKjBqGDJB2c0irULDsBgIw,22678
100
- orionis/luminate/container/container.py,sha256=SKC7IyiAaeySiSvlRbTZRTTe4i_Jvm2N8O9Di8It6_I,16350
100
+ orionis/luminate/container/container.py,sha256=RlGsAgUqSZa2bAvaxCtD3babXNUse7f3t9dDjz1scSg,16419
101
101
  orionis/luminate/container/exception.py,sha256=ap1SqYEjQEEHXJJTNmL7V1jrmRjgT5_7geZ95MYkhMA,1691
102
102
  orionis/luminate/container/types.py,sha256=BDcXN0__voRNHZ5Gr5dF0sWIYAQyNk4TxAwILBWyDAA,1735
103
103
  orionis/luminate/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -128,7 +128,7 @@ orionis/luminate/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
128
128
  orionis/luminate/services/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
129
129
  orionis/luminate/services/config/config_service.py,sha256=TZa3WZtDKEW6p0bMktzMXn85cOQy-q21myiYu3rZA34,2147
130
130
  orionis/luminate/services/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
131
- orionis/luminate/services/environment/environment_service.py,sha256=2XuzDxapUoiyyESyg2-hdx9xTyFjgAgVTOcvRx68uPg,2946
131
+ orionis/luminate/services/environment/environment_service.py,sha256=IgrfzLELNhnEuz9rn2lYBvv3JQrgiNCGLA34pQ__nxY,4136
132
132
  orionis/luminate/services/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
133
133
  orionis/luminate/services/files/path_resolver_service.py,sha256=E-G_E2H5QAZyxeMssARp7l1OBSxQurxkUPoKdSOCKEE,2041
134
134
  orionis/luminate/services/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -153,9 +153,9 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
153
153
  tests/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
154
154
  tests/tools/class_example.py,sha256=dIPD997Y15n6WmKhWoOFSwEldRm9MdOHTZZ49eF1p3c,1056
155
155
  tests/tools/test_reflection.py,sha256=bhLQ7VGVod4B8sv-rW9AjnOumvaBVsoxieA3sdoM2yM,5244
156
- orionis-0.68.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
157
- orionis-0.68.0.dist-info/METADATA,sha256=3D2zt3rbGf4vN_UIRT7pqDYGx4YX9_dPtBd47q9-vRY,2978
158
- orionis-0.68.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
159
- orionis-0.68.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
160
- orionis-0.68.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
161
- orionis-0.68.0.dist-info/RECORD,,
156
+ orionis-0.72.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
157
+ orionis-0.72.0.dist-info/METADATA,sha256=VbZCB0SHkobPg1dIxZA2g6Or8nHd8cjrzOkf62QRV7o,2978
158
+ orionis-0.72.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
159
+ orionis-0.72.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
160
+ orionis-0.72.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
161
+ orionis-0.72.0.dist-info/RECORD,,