orionis 0.226.0__py3-none-any.whl → 0.228.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.226.0"
8
+ VERSION = "0.228.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -0,0 +1,68 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any, Optional, Union
3
+
4
+ class IEnv(ABC):
5
+ """
6
+ Interface for a utility class to manage environment variables in a `.env` file.
7
+ """
8
+
9
+ @staticmethod
10
+ @abstractmethod
11
+ def get(key: str, default: Optional[Any] = None) -> Any:
12
+ """
13
+ Retrieve the value of an environment variable.
14
+
15
+ Parameters
16
+ ----------
17
+ key : str
18
+ Name of the environment variable.
19
+ default : Any, optional
20
+ Default value if variable is not found.
21
+
22
+ Returns
23
+ -------
24
+ Any
25
+ Parsed value or default.
26
+ """
27
+ pass
28
+
29
+ @staticmethod
30
+ @abstractmethod
31
+ def set(key: str, value: Union[str, int, float, bool, list, dict]) -> None:
32
+ """
33
+ Set the value of an environment variable.
34
+
35
+ Parameters
36
+ ----------
37
+ key : str
38
+ Name of the environment variable.
39
+ value : str, int, float, bool, list, or dict
40
+ Value to assign, will be serialized.
41
+ """
42
+ pass
43
+
44
+ @staticmethod
45
+ @abstractmethod
46
+ def unset(key: str) -> None:
47
+ """
48
+ Remove an environment variable.
49
+
50
+ Parameters
51
+ ----------
52
+ key : str
53
+ Name of the environment variable.
54
+ """
55
+ pass
56
+
57
+ @staticmethod
58
+ @abstractmethod
59
+ def all() -> dict:
60
+ """
61
+ Retrieve all environment variables as a dictionary.
62
+
63
+ Returns
64
+ -------
65
+ dict
66
+ Dictionary of parsed environment variables.
67
+ """
68
+ pass
@@ -1,13 +1,15 @@
1
1
  import os
2
2
  from typing import Any, Optional, Union
3
3
  from dotenv import set_key, unset_key, dotenv_values
4
+ from orionis.luminate.support.environment.contracts.env import IEnv
4
5
  from orionis.luminate.support.environment.functions import (
5
6
  _initialize,
6
7
  _parse_value,
7
8
  _serialize_value,
9
+ _delete_file
8
10
  )
9
11
 
10
- class Env:
12
+ class Env(IEnv):
11
13
  """
12
14
  A utility class for managing environment variables stored in a `.env` file.
13
15
  """
@@ -102,3 +104,35 @@ class Env:
102
104
  env_vars[key] = _parse_value(value)
103
105
 
104
106
  return env_vars
107
+
108
+ @staticmethod
109
+ def initialize() -> None:
110
+ """
111
+ Initializes the `.env` file if it does not exist.
112
+
113
+ Parameters
114
+ ----------
115
+ path : str or Path, optional
116
+ The path to the `.env` file. If None, a default path is used.
117
+
118
+ Returns
119
+ -------
120
+ None
121
+ """
122
+ _initialize()
123
+
124
+ @staticmethod
125
+ def destroy() -> None:
126
+ """
127
+ Deletes the `.env` file.
128
+
129
+ Parameters
130
+ ----------
131
+ path : str or Path, optional
132
+ The path to the `.env` file. If None, a default path is used.
133
+
134
+ Returns
135
+ -------
136
+ None
137
+ """
138
+ _delete_file()
@@ -38,4 +38,12 @@ def _serialize_value(value: Any) -> str:
38
38
  """
39
39
  if isinstance(value, (list, dict, bool, int, float)):
40
40
  return repr(value)
41
- return str(value)
41
+ return str(value)
42
+
43
+ def _delete_file() -> None:
44
+ """
45
+ Elimina el archivo especificado.
46
+ """
47
+ resolved_path = Path(os.getcwd()) / ".env"
48
+ if resolved_path.exists():
49
+ os.remove(resolved_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.226.0
3
+ Version: 0.228.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/console.py,sha256=4gYWxf0fWYgJ4RKwARvnTPh06FL3GJ6SAZ7R2NzOICw,1342
3
- orionis/framework.py,sha256=WYK-9gzaBegqDEoeIGgEf97ew3r9EJI00joFmIpMfb0,1458
3
+ orionis/framework.py,sha256=yvd4Qh0vImy8fXZUPVQya7sgXqCfXJMdu9FsRwpsthQ,1458
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
@@ -161,9 +161,11 @@ orionis/luminate/support/asynchrony/async_io.py,sha256=IkgVrJnnvNExkhy9brfZpTq2E
161
161
  orionis/luminate/support/asynchrony/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
162
162
  orionis/luminate/support/asynchrony/contracts/async_coroutine.py,sha256=lwtDa6r7I6qbxzKr5MyJtMRaYW6e5j2dbymEPNaNIEo,614
163
163
  orionis/luminate/support/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
164
- orionis/luminate/support/environment/env.py,sha256=MgFZ53fG77eugimdXfuYsbpXBadgi0KaM3b_DNB02D8,3291
165
- orionis/luminate/support/environment/functions.py,sha256=qiKc2oPaWwspSeUF0E8ZZYMsKlFDI1VGLl6vfpAnP4s,1129
164
+ orionis/luminate/support/environment/env.py,sha256=smBVhxIJr4U0RO6CzqtQJLEu_il2Exjpa_564o2PTcI,4085
165
+ orionis/luminate/support/environment/functions.py,sha256=L6gL4z3c89ZU17IWvOXyQ2_GdzA3XOmXeQpIpnQRios,1330
166
166
  orionis/luminate/support/environment/helper.py,sha256=G1670w1xkI1pj-rW_inv6D3XmU4oliwnWnrJO5CBm2E,818
167
+ orionis/luminate/support/environment/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
168
+ orionis/luminate/support/environment/contracts/env.py,sha256=buJfzebBOUuq2CnhQCWlnJuzJAEo06-S0_SPR4N_mOY,1647
167
169
  orionis/luminate/support/inspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
168
170
  orionis/luminate/support/inspection/container_integrity.py,sha256=6d9FsGk-Rm1AXgqBS3Nww49dR7n1ptXTTNyGUuBHgNY,10111
169
171
  orionis/luminate/support/inspection/functions.py,sha256=4wDT7iNp-5l4vuHk0UsIxN9wakASJRD4V0KY24uMDzk,7227
@@ -224,8 +226,7 @@ tests/support/adapters/fakes/fake_dict.py,sha256=KD48_xBc8pqj3LAe1_v1esu-1Fdz8fL
224
226
  tests/support/async_io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
225
227
  tests/support/async_io/test_async_coroutine.py,sha256=qXmpfyqaeNUSRQFdKVViGiF2FsRQle9VqyFeR-jAetg,1532
226
228
  tests/support/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
227
- tests/support/environment/test_env.py,sha256=jRJ2Xa7_cEnZg-1KzHOIDvGa0vQ-GxIw3u-MhuC3Aks,1899
228
- tests/support/environment/test_helper.py,sha256=YDTJMl-zAivnchPJMDzDh520GP73OL-nbU_LzRuZCeA,414
229
+ tests/support/environment/test_env.py,sha256=w1TyhnM-xSgAmFr42pEuwGOyww16EboumndY_agDWPA,2662
229
230
  tests/support/inspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
230
231
  tests/support/inspection/test_reflection_abstract.py,sha256=6w8vm8H_fR4Z-KYjQGm8bq-HcetlpQl0EsDmDy3WzQ8,9311
231
232
  tests/support/inspection/test_reflection_concrete.py,sha256=3BWSU7MkFEv2UgAVAwhiaMrzEwAyDBBJCa6edOENKSU,6782
@@ -248,9 +249,9 @@ tests/support/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
248
249
  tests/support/patterns/test_singleton.py,sha256=U5uwpgGcP7-fIazsnFLwg30mmc24S62udhVIHuL-scY,634
249
250
  tests/support/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
250
251
  tests/support/standard/test_std.py,sha256=bJ5LV_OKEEZa_Bk3PTk9Kapk6qECLzcKf0hfR_x2QqM,2042
251
- orionis-0.226.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
252
- orionis-0.226.0.dist-info/METADATA,sha256=rxazC_s4DLlzY7n4jvuU5xLvrOEXxgZDsWdlXJzs0Fw,3003
253
- orionis-0.226.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
254
- orionis-0.226.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
255
- orionis-0.226.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
256
- orionis-0.226.0.dist-info/RECORD,,
252
+ orionis-0.228.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
253
+ orionis-0.228.0.dist-info/METADATA,sha256=_wFvSjxKzyhc20WErhCgMTt0Hv9o9WpU8Qcsus_2PXk,3003
254
+ orionis-0.228.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
255
+ orionis-0.228.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
256
+ orionis-0.228.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
257
+ orionis-0.228.0.dist-info/RECORD,,
@@ -19,6 +19,9 @@ class TestsEnvironment(TestCase):
19
19
  result = Env.get('NON_EXISTENT_KEY', True)
20
20
  self.assertEqual(result, True)
21
21
 
22
+ # Delete File .env
23
+ Env.destroy()
24
+
22
25
  async def testSetEnvVariable(self):
23
26
  """
24
27
  Test setting an environment variable in the `.env` file.
@@ -31,6 +34,9 @@ class TestsEnvironment(TestCase):
31
34
  result = Env.get('TEST_KEY')
32
35
  self.assertEqual(result, 'NEW_VALUE')
33
36
 
37
+ # Delete File .env
38
+ Env.destroy()
39
+
34
40
  async def testUnsetEnvVariable(self):
35
41
  """
36
42
  Test removing an environment variable from the `.env` file.
@@ -44,6 +50,27 @@ class TestsEnvironment(TestCase):
44
50
  result = Env.get('TEST_KEY')
45
51
  self.assertIsNone(result)
46
52
 
53
+ # Delete File .env
54
+ Env.destroy()
55
+
56
+ async def testGetEnvHelper(self):
57
+ """"
58
+ Test retrieving an environment variable using the env helper.
59
+ """
60
+
61
+ # Mock the environment setup
62
+ Env.set('FRAMEWORK', 'https://github.com/orionis-framework/framework')
63
+
64
+ # Import the env helper and retrieve the variable
65
+ from orionis.luminate.support.environment.helper import env as get_env
66
+ result = get_env('FRAMEWORK')
67
+
68
+ # Verify the result
69
+ self.assertEqual(result, 'https://github.com/orionis-framework/framework')
70
+
71
+ # Delete File .env
72
+ Env.destroy()
73
+
47
74
  async def test_get_all_env_variables(self):
48
75
  """
49
76
  Test retrieving all environment variables from the `.env` file.
@@ -60,5 +87,5 @@ class TestsEnvironment(TestCase):
60
87
  self.assertEqual(result.get('KEY1'), 'value1')
61
88
  self.assertEqual(result.get('KEY2'), 'value2')
62
89
 
63
- Env.unset('KEY1')
64
- Env.unset('KEY2')
90
+ # Delete File .env
91
+ Env.destroy()
@@ -1,11 +0,0 @@
1
- from orionis.luminate.support.environment.helper import env
2
- from orionis.luminate.test.test_case import TestCase
3
-
4
- class TestsEnvironmentHelper(TestCase):
5
-
6
- async def testGetEnvHelper(self):
7
- """"
8
- Test retrieving an environment variable using the env helper.
9
- """
10
- result = env('FRAMEWORK')
11
- self.assertEqual(result, 'https://github.com/orionis-framework/framework')