orionis 0.68.0__py3-none-any.whl → 0.70.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.70.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,51 @@
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
10
  def __init__(self):
11
11
 
12
+ # Atributos de la clase
12
13
  self._config = {}
13
14
  self._commands = {}
15
+ self._environment = {}
14
16
 
17
+ # Inicializar el contenedor de la aplicacion
15
18
  self.container = Container()
16
19
  self.container.instance(self.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
+ def _loadServiceProviderEnvironment(self):
28
+
29
+ # Cargar el proveedor de entorno
30
+ _environment_provider = EnvironmentProvider(app=self.container)
31
+ _environment_provider.register()
32
+ _environment_provider.boot()
33
+
19
34
  def _bootstraping(self):
35
+
36
+ # Cargar la configuracion de la aplicacion
20
37
  config_bootstrapper_key = self.container.singleton(ConfigBootstrapper)
21
38
  config_bootstrapper: ConfigBootstrapper = self.container.make(config_bootstrapper_key)
22
39
  self._config = config_bootstrapper.get()
23
40
 
41
+ # Cargar los comandos propios y definidos por el desarrollador
24
42
  commands_bootstrapper_key = self.container.singleton(CommandsBootstrapper)
25
43
  commands_bootstrapper: CommandsBootstrapper = self.container.make(commands_bootstrapper_key)
26
44
  self._commands = commands_bootstrapper.get()
27
45
 
46
+ # Cargar las variables de entorno solo desde el archivo .env (No se carga desde el sistema operativo, por seguridad)
28
47
  environment_bootstrapper_key = self.container.singleton(EnvironmentBootstrapper)
29
48
  environment_bootstrapper: EnvironmentBootstrapper = self.container.make(environment_bootstrapper_key)
30
49
  self._environment = environment_bootstrapper.get()
31
50
 
32
- def isBooted(self):
33
- return True
51
+ print(self._config)
@@ -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
  """
@@ -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.70.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=X0Emcz86KeiYNUZkHybLDkL0DA4OOjMEpgp6KquLfrw,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=KHmx5YBiBX2LD-4k8YwUbwOEDv4Ke19rD-5aMLxvIx0,2286
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
@@ -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.70.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
157
+ orionis-0.70.0.dist-info/METADATA,sha256=YvDFh8uQw1pFuqduGSMEkhUCX1lh2mfDboTFjZ--KbU,2978
158
+ orionis-0.70.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
159
+ orionis-0.70.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
160
+ orionis-0.70.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
161
+ orionis-0.70.0.dist-info/RECORD,,