orionis 0.223.0__py3-none-any.whl → 0.225.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 +1 -1
- orionis/luminate/application.py +2 -3
- orionis/luminate/container/resolve.py +1 -2
- orionis/luminate/foundation/environment/environment_bootstrapper.py +3 -2
- orionis/luminate/support/environment/env.py +104 -0
- orionis/luminate/support/environment/functions.py +41 -0
- orionis/luminate/support/environment/helper.py +26 -0
- orionis/luminate/support/paths/__init__.py +0 -0
- orionis/luminate/support/paths/contracts/__init__.py +0 -0
- orionis/luminate/support/paths/contracts/resolver.py +67 -0
- orionis/luminate/support/paths/resolver.py +83 -0
- {orionis-0.223.0.dist-info → orionis-0.225.0.dist-info}/METADATA +1 -1
- {orionis-0.223.0.dist-info → orionis-0.225.0.dist-info}/RECORD +24 -14
- tests/support/environment/__init__.py +0 -0
- tests/support/environment/test_env.py +64 -0
- tests/support/environment/test_helper.py +11 -0
- tests/support/path/__init__.py +0 -0
- tests/support/path/test_resolver.py +33 -0
- orionis/luminate/services/environment/environment_service.py +0 -154
- orionis/luminate/services/files/path_resolver_service.py +0 -50
- /orionis/luminate/{services/environment → support/asynchrony/contracts}/__init__.py +0 -0
- /orionis/luminate/{services/files → support/environment}/__init__.py +0 -0
- {orionis-0.223.0.dist-info → orionis-0.225.0.dist-info}/LICENCE +0 -0
- {orionis-0.223.0.dist-info → orionis-0.225.0.dist-info}/WHEEL +0 -0
- {orionis-0.223.0.dist-info → orionis-0.225.0.dist-info}/entry_points.txt +0 -0
- {orionis-0.223.0.dist-info → orionis-0.225.0.dist-info}/top_level.txt +0 -0
orionis/framework.py
CHANGED
orionis/luminate/application.py
CHANGED
@@ -9,8 +9,7 @@ from orionis.luminate.foundation.console.command_bootstrapper import CommandsBoo
|
|
9
9
|
from orionis.luminate.foundation.environment.environment_bootstrapper import EnvironmentBootstrapper
|
10
10
|
from orionis.luminate.foundation.exceptions.exception_bootstrapper import BootstrapRuntimeError
|
11
11
|
from orionis.luminate.foundation.providers.service_providers_bootstrapper import ServiceProvidersBootstrapper
|
12
|
-
from orionis.luminate.patterns.singleton import SingletonMeta
|
13
|
-
from orionis.luminate.support.async.async_io import AsyncExecutor
|
12
|
+
from orionis.luminate.support.patterns.singleton import SingletonMeta
|
14
13
|
|
15
14
|
class Application(metaclass=SingletonMeta):
|
16
15
|
"""
|
@@ -156,7 +155,7 @@ class Application(metaclass=SingletonMeta):
|
|
156
155
|
"""
|
157
156
|
self._bootstrapping()
|
158
157
|
self._loadCommands()
|
159
|
-
AsyncExecutor.run(self._bootServiceProviders())
|
158
|
+
# AsyncExecutor.run(self._bootServiceProviders())
|
160
159
|
Application.boot()
|
161
160
|
|
162
161
|
async def _bootServiceProviders(self) -> None:
|
@@ -1,7 +1,6 @@
|
|
1
1
|
from typing import Any, Callable
|
2
2
|
from orionis.luminate.container.container import Container
|
3
3
|
from orionis.luminate.container.exception import OrionisContainerValueError
|
4
|
-
from orionis.luminate.support.async.async_io import AsyncExecutor
|
5
4
|
|
6
5
|
class Resolve:
|
7
6
|
"""
|
@@ -62,4 +61,4 @@ class Resolve:
|
|
62
61
|
)
|
63
62
|
|
64
63
|
# Resolve and return the service associated with the abstract or alias
|
65
|
-
return AsyncExecutor.run(container.make(abstract_or_alias))
|
64
|
+
# return AsyncExecutor.run(container.make(abstract_or_alias))
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from typing import Dict
|
2
2
|
from orionis.luminate.contracts.foundation.environment.environment_bootstrapper import IEnvironmentBootstrapper
|
3
|
-
from orionis.luminate.
|
3
|
+
from orionis.luminate.support.environment.env import Env
|
4
|
+
# from orionis.luminate.services.environment.environment_service import EnvironmentService
|
4
5
|
|
5
6
|
class EnvironmentBootstrapper(IEnvironmentBootstrapper):
|
6
7
|
"""
|
@@ -43,7 +44,7 @@ class EnvironmentBootstrapper(IEnvironmentBootstrapper):
|
|
43
44
|
If the file does not exist, it creates an empty `.env` file. If the file exists,
|
44
45
|
it loads the environment variables into the `_environment_vars` dictionary.
|
45
46
|
"""
|
46
|
-
environment_service =
|
47
|
+
environment_service =Env()
|
47
48
|
self._environment_vars = environment_service.all()
|
48
49
|
|
49
50
|
def get(self, key: str = None) -> str:
|
@@ -0,0 +1,104 @@
|
|
1
|
+
import os
|
2
|
+
from typing import Any, Optional, Union
|
3
|
+
from dotenv import set_key, unset_key, dotenv_values
|
4
|
+
from orionis.luminate.support.environment.functions import (
|
5
|
+
_initialize,
|
6
|
+
_parse_value,
|
7
|
+
_serialize_value,
|
8
|
+
)
|
9
|
+
|
10
|
+
class Env:
|
11
|
+
"""
|
12
|
+
A utility class for managing environment variables stored in a `.env` file.
|
13
|
+
"""
|
14
|
+
|
15
|
+
@staticmethod
|
16
|
+
def get(key: str, default: Optional[Any] = None) -> Any:
|
17
|
+
"""
|
18
|
+
Retrieves the value of an environment variable from the `.env` file.
|
19
|
+
|
20
|
+
Parameters
|
21
|
+
----------
|
22
|
+
path : str or Path, optional
|
23
|
+
The path to the `.env` file. If None, a default path is used.
|
24
|
+
key : str
|
25
|
+
The name of the environment variable to retrieve.
|
26
|
+
default : Any, optional
|
27
|
+
The default value to return if the variable is not found.
|
28
|
+
|
29
|
+
Returns
|
30
|
+
-------
|
31
|
+
Any
|
32
|
+
The value of the environment variable, parsed into its appropriate type,
|
33
|
+
or the default value if the variable is not found.
|
34
|
+
"""
|
35
|
+
resolved_path = _initialize()
|
36
|
+
value = dotenv_values(resolved_path).get(key) or os.getenv(key)
|
37
|
+
return _parse_value(value) if value is not None else default
|
38
|
+
|
39
|
+
@staticmethod
|
40
|
+
def set(key: str, value: Union[str, int, float, bool, list, dict]) -> None:
|
41
|
+
"""
|
42
|
+
Sets the value of an environment variable in the `.env` file.
|
43
|
+
|
44
|
+
Parameters
|
45
|
+
----------
|
46
|
+
path : str or Path, optional
|
47
|
+
The path to the `.env` file. If None, a default path is used.
|
48
|
+
key : str
|
49
|
+
The name of the environment variable to set.
|
50
|
+
value : str, int, float, bool, list, or dict
|
51
|
+
The value to assign to the environment variable. It will be serialized
|
52
|
+
before being stored.
|
53
|
+
|
54
|
+
Returns
|
55
|
+
-------
|
56
|
+
None
|
57
|
+
"""
|
58
|
+
resolved_path = _initialize()
|
59
|
+
serialized_value = _serialize_value(value)
|
60
|
+
set_key(str(resolved_path), key, serialized_value)
|
61
|
+
|
62
|
+
@staticmethod
|
63
|
+
def unset(key: str) -> None:
|
64
|
+
"""
|
65
|
+
Removes an environment variable from the `.env` file.
|
66
|
+
|
67
|
+
Parameters
|
68
|
+
----------
|
69
|
+
path : str or Path, optional
|
70
|
+
The path to the `.env` file. If None, a default path is used.
|
71
|
+
key : str
|
72
|
+
The name of the environment variable to remove.
|
73
|
+
|
74
|
+
Returns
|
75
|
+
-------
|
76
|
+
None
|
77
|
+
"""
|
78
|
+
resolved_path = _initialize()
|
79
|
+
unset_key(str(resolved_path), key)
|
80
|
+
|
81
|
+
@staticmethod
|
82
|
+
def all() -> dict:
|
83
|
+
"""
|
84
|
+
Retrieves all environment variables from the `.env` file.
|
85
|
+
|
86
|
+
Parameters
|
87
|
+
----------
|
88
|
+
path : str or Path, optional
|
89
|
+
The path to the `.env` file. If None, a default path is used.
|
90
|
+
|
91
|
+
Returns
|
92
|
+
-------
|
93
|
+
dict
|
94
|
+
A dictionary containing all environment variables from the `.env` file,
|
95
|
+
with their values parsed into their appropriate types.
|
96
|
+
"""
|
97
|
+
resolved_path = _initialize()
|
98
|
+
env_vars = {}
|
99
|
+
data = dotenv_values(resolved_path)
|
100
|
+
|
101
|
+
for key, value in data.items():
|
102
|
+
env_vars[key] = _parse_value(value)
|
103
|
+
|
104
|
+
return env_vars
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import ast
|
2
|
+
import os
|
3
|
+
from pathlib import Path
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
def _initialize() -> Path:
|
7
|
+
"""
|
8
|
+
Inicializa la ruta al archivo `.env`.
|
9
|
+
"""
|
10
|
+
resolved_path = Path(os.getcwd()) / ".env"
|
11
|
+
|
12
|
+
# Asegurarse de que el archivo .env exista
|
13
|
+
if not resolved_path.exists():
|
14
|
+
resolved_path.touch()
|
15
|
+
|
16
|
+
return resolved_path
|
17
|
+
|
18
|
+
def _parse_value(value: Any) -> Any:
|
19
|
+
"""
|
20
|
+
Parsea un valor de cadena en un tipo de dato de Python.
|
21
|
+
"""
|
22
|
+
value = str(value).strip() if value is not None else None
|
23
|
+
|
24
|
+
if not value or value.lower() in {'none', 'null'}:
|
25
|
+
return None
|
26
|
+
if value.lower() in {'true', 'false'}:
|
27
|
+
return value.lower() == 'true'
|
28
|
+
if value.isdigit():
|
29
|
+
return int(value)
|
30
|
+
try:
|
31
|
+
return ast.literal_eval(value)
|
32
|
+
except (ValueError, SyntaxError):
|
33
|
+
return value
|
34
|
+
|
35
|
+
def _serialize_value(value: Any) -> str:
|
36
|
+
"""
|
37
|
+
Serializa un tipo de dato de Python en una cadena para almacenarlo en el archivo `.env`.
|
38
|
+
"""
|
39
|
+
if isinstance(value, (list, dict, bool, int, float)):
|
40
|
+
return repr(value)
|
41
|
+
return str(value)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from orionis.luminate.support.environment.env import Env
|
3
|
+
|
4
|
+
def env(key: str, default = None) -> Any:
|
5
|
+
"""
|
6
|
+
Retrieves the value of an environment variable.
|
7
|
+
|
8
|
+
This function provides a convenient way to access environment variables
|
9
|
+
stored in the application context. If the variable does not exist, it
|
10
|
+
returns the specified default value.
|
11
|
+
|
12
|
+
Parameters
|
13
|
+
----------
|
14
|
+
key : str
|
15
|
+
The name of the environment variable to retrieve.
|
16
|
+
default : Any, optional
|
17
|
+
The default value to return if the environment variable does not exist.
|
18
|
+
Defaults to None.
|
19
|
+
|
20
|
+
Returns
|
21
|
+
-------
|
22
|
+
Any
|
23
|
+
The value of the environment variable, or the default value if the variable
|
24
|
+
does not exist.
|
25
|
+
"""
|
26
|
+
return Env.get(key, default)
|
File without changes
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
class IResolver(ABC):
|
5
|
+
"""
|
6
|
+
Interface for a utility class that resolves file and directory paths relative to a base path.
|
7
|
+
"""
|
8
|
+
|
9
|
+
@abstractmethod
|
10
|
+
def __init__(self, root_path: Optional[str] = None):
|
11
|
+
"""
|
12
|
+
Initializes the resolver with an optional root path.
|
13
|
+
|
14
|
+
Parameters
|
15
|
+
----------
|
16
|
+
root_path : str, optional
|
17
|
+
The root directory to resolve relative paths from.
|
18
|
+
"""
|
19
|
+
pass
|
20
|
+
|
21
|
+
@abstractmethod
|
22
|
+
def relativePath(self, relative_path: str):
|
23
|
+
"""
|
24
|
+
Resolves a relative path into an absolute one and validates its existence.
|
25
|
+
|
26
|
+
Parameters
|
27
|
+
----------
|
28
|
+
relative_path : str
|
29
|
+
The relative path to resolve.
|
30
|
+
|
31
|
+
Returns
|
32
|
+
-------
|
33
|
+
ResolverInterface
|
34
|
+
The instance itself for method chaining.
|
35
|
+
|
36
|
+
Raises
|
37
|
+
------
|
38
|
+
FileNotFoundError
|
39
|
+
If the resolved path does not exist.
|
40
|
+
ValueError
|
41
|
+
If the resolved path is neither a file nor a directory.
|
42
|
+
"""
|
43
|
+
pass
|
44
|
+
|
45
|
+
@abstractmethod
|
46
|
+
def toString(self) -> str:
|
47
|
+
"""
|
48
|
+
Returns the resolved path as a string.
|
49
|
+
|
50
|
+
Returns
|
51
|
+
-------
|
52
|
+
str
|
53
|
+
The resolved path.
|
54
|
+
"""
|
55
|
+
pass
|
56
|
+
|
57
|
+
@abstractmethod
|
58
|
+
def __str__(self) -> str:
|
59
|
+
"""
|
60
|
+
Returns the resolved path as a string (for print or str()).
|
61
|
+
|
62
|
+
Returns
|
63
|
+
-------
|
64
|
+
str
|
65
|
+
The resolved path.
|
66
|
+
"""
|
67
|
+
pass
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import os
|
2
|
+
from pathlib import Path
|
3
|
+
from orionis.luminate.support.paths.contracts.resolver import IResolver
|
4
|
+
|
5
|
+
class Resolver(IResolver):
|
6
|
+
"""
|
7
|
+
A utility class for resolving file and directory paths relative to the project's root directory.
|
8
|
+
"""
|
9
|
+
|
10
|
+
def __init__(self, root_path: str = None):
|
11
|
+
"""
|
12
|
+
Initializes the Resolver instance with the project's root directory.
|
13
|
+
|
14
|
+
Parameters
|
15
|
+
----------
|
16
|
+
root_path : str, optional
|
17
|
+
The root directory of the project. If not provided, it defaults to the current working directory.
|
18
|
+
"""
|
19
|
+
self.base_path = Path(root_path).resolve() if root_path else Path(os.getcwd()).resolve()
|
20
|
+
self.resolved_path = None
|
21
|
+
|
22
|
+
def relativePath(self, relative_path: str) -> 'Resolver':
|
23
|
+
"""
|
24
|
+
Resolves a given relative path to an absolute path and validates its existence.
|
25
|
+
|
26
|
+
This method combines the project's root directory with the provided relative path,
|
27
|
+
resolves it to an absolute path, and ensures it exists as either a directory or a file.
|
28
|
+
|
29
|
+
Parameters
|
30
|
+
----------
|
31
|
+
relative_path : str
|
32
|
+
The relative path to a directory or file to be resolved.
|
33
|
+
|
34
|
+
Returns
|
35
|
+
-------
|
36
|
+
Resolver
|
37
|
+
The current instance of the Resolver class with the resolved path.
|
38
|
+
|
39
|
+
Raises
|
40
|
+
------
|
41
|
+
FileNotFoundError
|
42
|
+
If the resolved path does not exist.
|
43
|
+
ValueError
|
44
|
+
If the resolved path is neither a valid directory nor a file.
|
45
|
+
"""
|
46
|
+
# Combine the base path with the relative path and resolve it
|
47
|
+
resolved_path = (self.base_path / relative_path).resolve()
|
48
|
+
|
49
|
+
# Validate that the path exists
|
50
|
+
if not resolved_path.exists():
|
51
|
+
raise FileNotFoundError(f"The requested path does not exist: {resolved_path}")
|
52
|
+
|
53
|
+
# Validate that the path is either a directory or a file
|
54
|
+
if not (resolved_path.is_dir() or resolved_path.is_file()):
|
55
|
+
raise ValueError(f"The requested path is neither a valid directory nor a file: {resolved_path}")
|
56
|
+
|
57
|
+
# Store the resolved path in the instance variable
|
58
|
+
self.resolved_path = resolved_path
|
59
|
+
|
60
|
+
# Return the current instance
|
61
|
+
return self
|
62
|
+
|
63
|
+
def toString(self) -> str:
|
64
|
+
"""
|
65
|
+
Returns the string representation of the resolved path.
|
66
|
+
|
67
|
+
Returns
|
68
|
+
-------
|
69
|
+
str
|
70
|
+
The resolved path as a string.
|
71
|
+
"""
|
72
|
+
return str(self.resolved_path)
|
73
|
+
|
74
|
+
def __str__(self) -> str:
|
75
|
+
"""
|
76
|
+
Returns the string representation of the resolved path.
|
77
|
+
|
78
|
+
Returns
|
79
|
+
-------
|
80
|
+
str
|
81
|
+
The resolved path as a string.
|
82
|
+
"""
|
83
|
+
return str(self.resolved_path)
|
@@ -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=
|
3
|
+
orionis/framework.py,sha256=TmXoK20GzRH5EFAjlvUZYkiWA9JLEqDtzW0SOPe8rCs,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
|
@@ -10,7 +10,7 @@ orionis/installer/contracts/manager.py,sha256=Zfndhuyu0JaTKo3PsGsKmVsvotQMw8Pmt4
|
|
10
10
|
orionis/installer/contracts/output.py,sha256=t1KLw610-hHy63UbFFE2BYwWHWRbW8_ofuEvRLx_IUE,983
|
11
11
|
orionis/installer/contracts/setup.py,sha256=aWYkCv-z48bXXZynYapc3uMIE1gyO6XnkTw3b4MTBq4,784
|
12
12
|
orionis/luminate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
-
orionis/luminate/application.py,sha256=
|
13
|
+
orionis/luminate/application.py,sha256=6pnmBJVjiTY8O0MXfCXt1nX7PzslBPTFyol_3uwjqnQ,9475
|
14
14
|
orionis/luminate/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
15
|
orionis/luminate/config/app.py,sha256=o-Ons0LMp77_E18e_dx_DqGVbjaY2l-5RdVSCILxgfg,1655
|
16
16
|
orionis/luminate/config/auth.py,sha256=ivAUgoEYEtfdC49vDwOl_MXFUVAQnUJTc8iG3Lu0Stc,430
|
@@ -48,7 +48,7 @@ orionis/luminate/container/container.py,sha256=9xdODX1h4YK6V-THrfgm5XN95imobExzr
|
|
48
48
|
orionis/luminate/container/container_integrity.py,sha256=6d9FsGk-Rm1AXgqBS3Nww49dR7n1ptXTTNyGUuBHgNY,10111
|
49
49
|
orionis/luminate/container/exception.py,sha256=ap1SqYEjQEEHXJJTNmL7V1jrmRjgT5_7geZ95MYkhMA,1691
|
50
50
|
orionis/luminate/container/lifetimes.py,sha256=2lbdiV7R2WlJf1cLD6eBxLnJud_lZvX1IhQH2Djy3Ww,375
|
51
|
-
orionis/luminate/container/resolve.py,sha256=
|
51
|
+
orionis/luminate/container/resolve.py,sha256=JW-jep8Qo6SEA8owpiqcaKc5SdzIL2x_Wmr1kFwj3lQ,2247
|
52
52
|
orionis/luminate/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
53
53
|
orionis/luminate/contracts/application.py,sha256=FIR6WMY0y-Hkjp0jWfjJV9kwIqBb-RB1-Jl0GWCk9eI,1077
|
54
54
|
orionis/luminate/contracts/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -126,7 +126,7 @@ orionis/luminate/foundation/config/config_bootstrapper.py,sha256=Zdk3C-asIc0zizR
|
|
126
126
|
orionis/luminate/foundation/console/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
127
127
|
orionis/luminate/foundation/console/command_bootstrapper.py,sha256=o1R3puuDyRIf3KXfxyluj6KixPTg96JD2V6TYKLOonw,7064
|
128
128
|
orionis/luminate/foundation/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
129
|
-
orionis/luminate/foundation/environment/environment_bootstrapper.py,sha256=
|
129
|
+
orionis/luminate/foundation/environment/environment_bootstrapper.py,sha256=5CUT4HZJTxaqYw2PUIkjXLlUZhfzNHohOvw0dY3McBY,2771
|
130
130
|
orionis/luminate/foundation/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
131
131
|
orionis/luminate/foundation/exceptions/exception_bootstrapper.py,sha256=wDKfEW295c7-bavr7YUHK2CLYcTSZgjT9ZRSBne6GOE,1356
|
132
132
|
orionis/luminate/foundation/exceptions/exception_providers.py,sha256=VxrzuDRKXn8b73xKINPb-FxBusUz8ITXCu0KZh7Pm2o,1329
|
@@ -151,10 +151,6 @@ orionis/luminate/services/commands/reactor_commands_service.py,sha256=oca_xPEQ_d
|
|
151
151
|
orionis/luminate/services/commands/scheduler_service.py,sha256=mKy5I293GtpH98U4rOGXvcpqYwPVvp1cfceXdk53dsQ,22483
|
152
152
|
orionis/luminate/services/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
153
153
|
orionis/luminate/services/config/config_service.py,sha256=RKZ194_0RAEkRFSm3OPoDDdme0_wyBZNLaEQhIVdbYk,2114
|
154
|
-
orionis/luminate/services/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
155
|
-
orionis/luminate/services/environment/environment_service.py,sha256=GdrXWmOK2lWpa6GkIwFI8kHee5hQel_cIF9sduRfGfo,4776
|
156
|
-
orionis/luminate/services/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
157
|
-
orionis/luminate/services/files/path_resolver_service.py,sha256=gCGVLtdXGuEIE6I8tm6JEB84HS1Fa5rk2whO2R6u8Wc,1698
|
158
154
|
orionis/luminate/services/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
159
155
|
orionis/luminate/services/log/log_service.py,sha256=jrCrKz7Uj6n_ri-v5A4YOILQGUQ9MAmrlSizbbOvKhI,8303
|
160
156
|
orionis/luminate/support/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -162,7 +158,12 @@ orionis/luminate/support/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
|
|
162
158
|
orionis/luminate/support/adapters/dot_dict.py,sha256=FVHfBuAGTTVMjNG01Fix645fRNKKUMmNx61pYkxPL5c,1253
|
163
159
|
orionis/luminate/support/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
164
160
|
orionis/luminate/support/asynchrony/async_io.py,sha256=IkgVrJnnvNExkhy9brfZpTq2EXptyg3ZB2_ZSH9xDe8,1591
|
161
|
+
orionis/luminate/support/asynchrony/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
165
162
|
orionis/luminate/support/asynchrony/contracts/async_coroutine.py,sha256=lwtDa6r7I6qbxzKr5MyJtMRaYW6e5j2dbymEPNaNIEo,614
|
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
|
166
|
+
orionis/luminate/support/environment/helper.py,sha256=G1670w1xkI1pj-rW_inv6D3XmU4oliwnWnrJO5CBm2E,818
|
166
167
|
orionis/luminate/support/inspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
167
168
|
orionis/luminate/support/inspection/container_integrity.py,sha256=6d9FsGk-Rm1AXgqBS3Nww49dR7n1ptXTTNyGUuBHgNY,10111
|
168
169
|
orionis/luminate/support/inspection/functions.py,sha256=4wDT7iNp-5l4vuHk0UsIxN9wakASJRD4V0KY24uMDzk,7227
|
@@ -181,6 +182,10 @@ orionis/luminate/support/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
|
|
181
182
|
orionis/luminate/support/parsers/exception_parser.py,sha256=6MTeql76c1Muh9Nn-jz2jJdzb9_F7SLdoFjqBD5F8lY,3642
|
182
183
|
orionis/luminate/support/parsers/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
183
184
|
orionis/luminate/support/parsers/contracts/exception_parser.py,sha256=HcWN7nJrvD7xLREPKEnBhyG30IkkAB7Bx_hGpcfb0ZE,912
|
185
|
+
orionis/luminate/support/paths/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
186
|
+
orionis/luminate/support/paths/resolver.py,sha256=hsJCY0kvYGqSGuiZL-IdVp2YShiaOvbWKcbwqTHc9X0,2829
|
187
|
+
orionis/luminate/support/paths/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
188
|
+
orionis/luminate/support/paths/contracts/resolver.py,sha256=v7uTgByE2nQS2ZM_b1rtMzY6HH03MNKfAYQoTswPf9o,1627
|
184
189
|
orionis/luminate/support/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
185
190
|
orionis/luminate/support/patterns/singleton.py,sha256=b3U0nubKSQWyal5wTXADVPtOztkaTk-M8Zwy-bje1L0,1425
|
186
191
|
orionis/luminate/support/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -218,6 +223,9 @@ tests/support/adapters/fakes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
|
|
218
223
|
tests/support/adapters/fakes/fake_dict.py,sha256=KD48_xBc8pqj3LAe1_v1esu-1Fdz8fL5eZ70LSqkcbg,393
|
219
224
|
tests/support/async_io/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
220
225
|
tests/support/async_io/test_async_coroutine.py,sha256=qXmpfyqaeNUSRQFdKVViGiF2FsRQle9VqyFeR-jAetg,1532
|
226
|
+
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
|
221
229
|
tests/support/inspection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
222
230
|
tests/support/inspection/test_reflection_abstract.py,sha256=6w8vm8H_fR4Z-KYjQGm8bq-HcetlpQl0EsDmDy3WzQ8,9311
|
223
231
|
tests/support/inspection/test_reflection_concrete.py,sha256=3BWSU7MkFEv2UgAVAwhiaMrzEwAyDBBJCa6edOENKSU,6782
|
@@ -234,13 +242,15 @@ tests/support/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
|
|
234
242
|
tests/support/parsers/test_exception_parser.py,sha256=s-ZRbxyr9bs5uis2SM0IN-vCc-AJhWqRnEMIVgeEFXE,2363
|
235
243
|
tests/support/parsers/fakes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
236
244
|
tests/support/parsers/fakes/fake_custom_error.py,sha256=BD8tQPhmIYFYVcaeMpEQ6uK1d6pcU4EGbwRkVfCZp7c,802
|
245
|
+
tests/support/path/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
246
|
+
tests/support/path/test_resolver.py,sha256=VkHeHu87Hmmq4_mHB6jM8OsjxDyWgB-5E7KGAn-dRe0,1258
|
237
247
|
tests/support/patterns/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
238
248
|
tests/support/patterns/test_singleton.py,sha256=U5uwpgGcP7-fIazsnFLwg30mmc24S62udhVIHuL-scY,634
|
239
249
|
tests/support/standard/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
240
250
|
tests/support/standard/test_std.py,sha256=bJ5LV_OKEEZa_Bk3PTk9Kapk6qECLzcKf0hfR_x2QqM,2042
|
241
|
-
orionis-0.
|
242
|
-
orionis-0.
|
243
|
-
orionis-0.
|
244
|
-
orionis-0.
|
245
|
-
orionis-0.
|
246
|
-
orionis-0.
|
251
|
+
orionis-0.225.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
252
|
+
orionis-0.225.0.dist-info/METADATA,sha256=B0oTyxhlmB97eRjZp_pOy3H3-kfEz7qHBTOYiB0AAUw,3003
|
253
|
+
orionis-0.225.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
254
|
+
orionis-0.225.0.dist-info/entry_points.txt,sha256=a_e0faeSqyUCVZd0MqljQ2oaHHdlsz6g9sU_bMqi5zQ,49
|
255
|
+
orionis-0.225.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
256
|
+
orionis-0.225.0.dist-info/RECORD,,
|
File without changes
|
@@ -0,0 +1,64 @@
|
|
1
|
+
from orionis.luminate.support.environment.env import Env
|
2
|
+
from orionis.luminate.test.test_case import TestCase
|
3
|
+
|
4
|
+
class TestsEnvironment(TestCase):
|
5
|
+
|
6
|
+
async def testGetEnvVariable(self):
|
7
|
+
"""
|
8
|
+
Test retrieving an environment variable from the `.env` file.
|
9
|
+
"""
|
10
|
+
|
11
|
+
# Mock the environment setup
|
12
|
+
Env.set('TEST_KEY', 'TEST_VALUE')
|
13
|
+
|
14
|
+
# Test the get method
|
15
|
+
result = Env.get('TEST_KEY')
|
16
|
+
self.assertEqual(result, "TEST_VALUE")
|
17
|
+
|
18
|
+
# Test with a non-existent key
|
19
|
+
result = Env.get('NON_EXISTENT_KEY', True)
|
20
|
+
self.assertEqual(result, True)
|
21
|
+
|
22
|
+
async def testSetEnvVariable(self):
|
23
|
+
"""
|
24
|
+
Test setting an environment variable in the `.env` file.
|
25
|
+
"""
|
26
|
+
|
27
|
+
# Set the environment variable
|
28
|
+
Env.set('TEST_KEY', 'NEW_VALUE')
|
29
|
+
|
30
|
+
# Verify the value was set correctly
|
31
|
+
result = Env.get('TEST_KEY')
|
32
|
+
self.assertEqual(result, 'NEW_VALUE')
|
33
|
+
|
34
|
+
async def testUnsetEnvVariable(self):
|
35
|
+
"""
|
36
|
+
Test removing an environment variable from the `.env` file.
|
37
|
+
"""
|
38
|
+
|
39
|
+
# Set and then unset the environment variable
|
40
|
+
Env.set('TEST_KEY', "TEST_VALUE")
|
41
|
+
Env.unset('TEST_KEY')
|
42
|
+
|
43
|
+
# Verify the variable was removed
|
44
|
+
result = Env.get('TEST_KEY')
|
45
|
+
self.assertIsNone(result)
|
46
|
+
|
47
|
+
async def test_get_all_env_variables(self):
|
48
|
+
"""
|
49
|
+
Test retrieving all environment variables from the `.env` file.
|
50
|
+
"""
|
51
|
+
|
52
|
+
# Mock the environment setup
|
53
|
+
Env.set('KEY1', 'value1')
|
54
|
+
Env.set('KEY2', 'value2')
|
55
|
+
|
56
|
+
# Retrieve all environment variables
|
57
|
+
result = Env.all()
|
58
|
+
|
59
|
+
# Verify the result
|
60
|
+
self.assertEqual(result.get('KEY1'), 'value1')
|
61
|
+
self.assertEqual(result.get('KEY2'), 'value2')
|
62
|
+
|
63
|
+
Env.unset('KEY1')
|
64
|
+
Env.unset('KEY2')
|
@@ -0,0 +1,11 @@
|
|
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')
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
from orionis.luminate.support.paths.resolver import Resolver
|
2
|
+
from orionis.luminate.test.test_case import TestCase
|
3
|
+
|
4
|
+
class TestsResolver(TestCase):
|
5
|
+
|
6
|
+
async def testFileNotFound(self):
|
7
|
+
"""
|
8
|
+
Test the Resolver class for a non-existent file path.
|
9
|
+
"""
|
10
|
+
file_path = "non_existent_file.txt"
|
11
|
+
with self.assertRaises(FileNotFoundError):
|
12
|
+
Resolver().relativePath(file_path)
|
13
|
+
|
14
|
+
async def testValidFilePath(self):
|
15
|
+
"""
|
16
|
+
Test the Resolver class for a valid file path.
|
17
|
+
"""
|
18
|
+
path = Resolver().relativePath('orionis/luminate/test/test_suite.py').toString()
|
19
|
+
self.assertTrue(path.endswith('test_suite.py'))
|
20
|
+
|
21
|
+
async def testOtherBasePath(self):
|
22
|
+
"""
|
23
|
+
Test the Resolver class for a different base path.
|
24
|
+
"""
|
25
|
+
path = Resolver('orionis/luminate/test').relativePath('test_suite.py').toString()
|
26
|
+
self.assertTrue(path.endswith('test_suite.py'))
|
27
|
+
|
28
|
+
async def testEqualOutputString(self):
|
29
|
+
"""
|
30
|
+
Test the Resolver class for a string representation of the resolved path.
|
31
|
+
"""
|
32
|
+
path = Resolver().relativePath('orionis/luminate/test/test_suite.py')
|
33
|
+
self.assertEqual(path.toString(), str(path))
|
@@ -1,154 +0,0 @@
|
|
1
|
-
import ast
|
2
|
-
import os
|
3
|
-
from pathlib import Path
|
4
|
-
from typing import Any
|
5
|
-
from dotenv import set_key, unset_key, dotenv_values
|
6
|
-
|
7
|
-
def env(key: str, default = None) -> Any:
|
8
|
-
"""
|
9
|
-
Retrieves the value of an environment variable.
|
10
|
-
|
11
|
-
This function provides a convenient way to access environment variables
|
12
|
-
stored in the application context. If the variable does not exist, it
|
13
|
-
returns the specified default value.
|
14
|
-
|
15
|
-
Parameters
|
16
|
-
----------
|
17
|
-
key : str
|
18
|
-
The name of the environment variable to retrieve.
|
19
|
-
default : Any, optional
|
20
|
-
The default value to return if the environment variable does not exist.
|
21
|
-
Defaults to None.
|
22
|
-
|
23
|
-
Returns
|
24
|
-
-------
|
25
|
-
Any
|
26
|
-
The value of the environment variable, or the default value if the variable
|
27
|
-
does not exist.
|
28
|
-
"""
|
29
|
-
return EnvironmentService().get(key, default)
|
30
|
-
|
31
|
-
class EnvironmentService:
|
32
|
-
|
33
|
-
def __init__(self, path: str = None):
|
34
|
-
|
35
|
-
"""
|
36
|
-
Initializes the EnvironmentService instance.
|
37
|
-
|
38
|
-
Parameters
|
39
|
-
----------
|
40
|
-
path : str, optional
|
41
|
-
The path to the .env file. Defaults to None.
|
42
|
-
"""
|
43
|
-
self._initialize(path)
|
44
|
-
|
45
|
-
def _initialize(self, path: str = None):
|
46
|
-
"""
|
47
|
-
Initializes the instance by setting the path to the .env file.
|
48
|
-
If no path is provided, defaults to a `.env` file in the current directory.
|
49
|
-
|
50
|
-
Parameters
|
51
|
-
----------
|
52
|
-
path : str, optional
|
53
|
-
Path to the .env file. Defaults to None.
|
54
|
-
"""
|
55
|
-
# Set the path to the .env file
|
56
|
-
self.path = Path(path) if path else Path(os.getcwd()) / ".env"
|
57
|
-
|
58
|
-
# Create the .env file if it does not exist
|
59
|
-
if not self.path.exists():
|
60
|
-
self.path.touch()
|
61
|
-
|
62
|
-
def get(self, key: str, default=None) -> str:
|
63
|
-
"""
|
64
|
-
Retrieves the value of an environment variable from the .env file
|
65
|
-
or from system environment variables if not found.
|
66
|
-
|
67
|
-
Parameters
|
68
|
-
----------
|
69
|
-
key : str
|
70
|
-
The key of the environment variable.
|
71
|
-
default : optional
|
72
|
-
Default value if the key does not exist. Defaults to None.
|
73
|
-
|
74
|
-
Returns
|
75
|
-
-------
|
76
|
-
str
|
77
|
-
The value of the environment variable or the default value.
|
78
|
-
"""
|
79
|
-
|
80
|
-
# Get the value from the .env file
|
81
|
-
value = dotenv_values(self.path).get(key)
|
82
|
-
|
83
|
-
# Get the value from the system environment variables if not found
|
84
|
-
if value is None:
|
85
|
-
value = os.getenv(key)
|
86
|
-
|
87
|
-
# Parse the value and return it
|
88
|
-
return self._parse_value(value) if value is not None else default
|
89
|
-
|
90
|
-
def set(self, key: str, value: str) -> None:
|
91
|
-
"""
|
92
|
-
Sets the value of an environment variable in the .env file.
|
93
|
-
|
94
|
-
Parameters
|
95
|
-
----------
|
96
|
-
key : str
|
97
|
-
The key of the environment variable.
|
98
|
-
value : str
|
99
|
-
The value to set.
|
100
|
-
"""
|
101
|
-
# Set the value in the .env file
|
102
|
-
set_key(str(self.path), key, value)
|
103
|
-
|
104
|
-
def unset(self, key: str) -> None:
|
105
|
-
"""
|
106
|
-
Removes an environment variable from the .env file.
|
107
|
-
|
108
|
-
Parameters
|
109
|
-
----------
|
110
|
-
key : str
|
111
|
-
The key of the environment variable to remove.
|
112
|
-
"""
|
113
|
-
# Remove the key from the .env file
|
114
|
-
unset_key(str(self.path), key)
|
115
|
-
|
116
|
-
def all(self) -> dict:
|
117
|
-
"""
|
118
|
-
Retrieves all environment variable values from the .env file.
|
119
|
-
|
120
|
-
Returns
|
121
|
-
-------
|
122
|
-
dict
|
123
|
-
A dictionary of all environment variables and their values.
|
124
|
-
"""
|
125
|
-
# Return all environment variables
|
126
|
-
env_vars = {}
|
127
|
-
|
128
|
-
# Get all environment variables from the .env file
|
129
|
-
data = dotenv_values(self.path)
|
130
|
-
for key, value in data.items():
|
131
|
-
# Parse the value and add it to the dictionary
|
132
|
-
env_vars[key] = self._parse_value(value)
|
133
|
-
|
134
|
-
# Get all environment variables from the system environment variables
|
135
|
-
return env_vars
|
136
|
-
|
137
|
-
def _parse_value(self, value : Any):
|
138
|
-
|
139
|
-
# Strip leading and trailing whitespace from the value
|
140
|
-
value = str(value).strip() if value is not None else None
|
141
|
-
|
142
|
-
# Parse common types and Python literals
|
143
|
-
if not value or value.lower() in {'none', 'null'}:
|
144
|
-
return None
|
145
|
-
if value.lower() in {'true', 'false'}:
|
146
|
-
return value.lower() == 'true'
|
147
|
-
if value.isdigit():
|
148
|
-
return int(value)
|
149
|
-
|
150
|
-
# Attempt to parse Python literals (e.g., lists, dictionaries)
|
151
|
-
try:
|
152
|
-
return ast.literal_eval(value)
|
153
|
-
except (ValueError, SyntaxError):
|
154
|
-
return value
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
from pathlib import Path
|
3
|
-
|
4
|
-
class PathResolverService:
|
5
|
-
|
6
|
-
def __init__(self):
|
7
|
-
"""
|
8
|
-
Override the __new__ method to ensure only one instance of the class is created.
|
9
|
-
|
10
|
-
Returns
|
11
|
-
-------
|
12
|
-
PathResolverService
|
13
|
-
The singleton instance of the PathResolverService class.
|
14
|
-
"""
|
15
|
-
self.base_path = Path(os.getcwd())
|
16
|
-
|
17
|
-
def resolve(self, route: str) -> str:
|
18
|
-
"""
|
19
|
-
Resolves and returns the absolute path as a string.
|
20
|
-
|
21
|
-
This method combines the base path (current working directory) with the provided
|
22
|
-
relative path, resolves it to an absolute path, and validates that it exists
|
23
|
-
and is either a directory or a file.
|
24
|
-
|
25
|
-
Parameters
|
26
|
-
----------
|
27
|
-
route : str
|
28
|
-
The relative directory or file path to be resolved.
|
29
|
-
|
30
|
-
Returns
|
31
|
-
-------
|
32
|
-
str
|
33
|
-
The absolute path to the directory or file.
|
34
|
-
|
35
|
-
Raises
|
36
|
-
------
|
37
|
-
PathNotFoundError
|
38
|
-
If the resolved path does not exist or is neither a directory nor a file.
|
39
|
-
"""
|
40
|
-
# Combine base path with the relative route
|
41
|
-
real_path = (self.base_path / route).resolve()
|
42
|
-
|
43
|
-
# Validate that the path exists and is either a directory or a file
|
44
|
-
if not str(real_path).endswith('.log'):
|
45
|
-
if not real_path.exists():
|
46
|
-
raise Exception(f"The requested path does not exist or is invalid: {real_path}")
|
47
|
-
if not (real_path.is_dir() or real_path.is_file()):
|
48
|
-
raise Exception(f"The requested path does not exist or is invalid: {real_path}")
|
49
|
-
|
50
|
-
return str(real_path)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|