orionis 0.59.0__tar.gz → 0.62.0__tar.gz
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-0.59.0/orionis.egg-info → orionis-0.62.0}/PKG-INFO +1 -1
- {orionis-0.59.0 → orionis-0.62.0}/orionis/framework.py +1 -1
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/app.py +6 -1
- orionis-0.62.0/orionis/luminate/bootstrap/environment_bootstrapper.py +138 -0
- {orionis-0.59.0 → orionis-0.62.0/orionis.egg-info}/PKG-INFO +1 -1
- orionis-0.59.0/orionis/luminate/bootstrap/environment_bootstrapper.py +0 -67
- {orionis-0.59.0 → orionis-0.62.0}/LICENCE +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/MANIFEST.in +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/README.md +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/cli_manager.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/bootstrap/i_command_bootstrapper.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/bootstrap/i_config_bootstrapper.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/bootstrap/i_environment_bootstrapper.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/config/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/config/i_config.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/base/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/base/i_command.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/i_command_filter.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/i_kernel.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/i_parser.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/i_task_manager.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/output/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/output/i_console.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/output/i_executor.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/output/i_progress_bar.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/tasks/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/console/tasks/i_schedule.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/container/i_container.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/container/i_types.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/config/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/config/i_config_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/environment/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/environment/i_environment_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/files/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/files/i_path_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/log/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/log/i_log_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/tests/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/tests/i_tests_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/installer/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/installer/i_installer_manager.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/installer/i_installer_output.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/installer/i_installer_setup.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/providers/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/providers/i_service_provider.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/services/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/services/config/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/services/config/i_config_service.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/services/files/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/services/files/i_path_service.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/services/log/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/services/log/i_log_service.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/support/i_exception_to_dict.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/support/i_reflection.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/support/i_std.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/installer/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/installer/installer_manager.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/installer/installer_output.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/installer/installer_setup.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/app_context.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/bootstrap/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/bootstrap/command_bootstrapper.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/bootstrap/config_bootstrapper.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/bootstrap/exception_bootstrapper.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/app.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/auth.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/cache.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/cors.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/database.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/filesystems.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/logging.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/mail.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/queue.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/config/session.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/base/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/base/command.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/command_filter.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/commands/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/commands/cache_clear.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/commands/help.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/commands/schedule_work.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/commands/tests.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/commands/version.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/exceptions/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/exceptions/cli_exception.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/kernel.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/output/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/output/console.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/output/executor.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/output/progress_bar.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/output/styles.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/parser.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/runner.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/tasks/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/console/tasks/scheduler.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/container/container.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/container/exception.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/container/types.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/config/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/config/config_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/environment/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/environment/environment_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/files/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/files/path_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/log/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/log/log_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/tests/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/tests/tests_facade.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/patterns/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/patterns/singleton.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/pipelines/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/pipelines/cli_pipeline.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/providers/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/providers/config/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/providers/config/config_service_provider.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/providers/log/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/providers/log/log_service_provider.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/services/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/services/config/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/services/config/config_service.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/services/files/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/services/files/path_service.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/services/log/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/services/log/log_service.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/support/dot_dict.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/support/exception_to_dict.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/support/reflection.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/support/std.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/test/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/test/exception.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/test/unit_test.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/static/ascii/icon.ascii +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/static/ascii/info.ascii +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/static/bg/galaxy.jpg +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/static/favicon/OrionisFrameworkFavicon.png +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/static/logos/OrionisFramework.jpg +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/static/logos/OrionisFramework.png +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/static/logos/OrionisFramework.psd +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/static/logos/OrionisFramework2.png +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis/static/logos/OrionisFramework3.png +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis.egg-info/SOURCES.txt +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis.egg-info/dependency_links.txt +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis.egg-info/entry_points.txt +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis.egg-info/requires.txt +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/orionis.egg-info/top_level.txt +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/setup.cfg +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/setup.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/tests/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/tests/tools/__init__.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/tests/tools/class_example.py +0 -0
- {orionis-0.59.0 → orionis-0.62.0}/tests/tools/test_reflection.py +0 -0
@@ -1,6 +1,8 @@
|
|
1
|
+
import json
|
1
2
|
from orionis.luminate.container.container import Container
|
2
3
|
from orionis.luminate.bootstrap.config_bootstrapper import ConfigBootstrapper
|
3
4
|
from orionis.luminate.bootstrap.command_bootstrapper import CommandsBootstrapper
|
5
|
+
from orionis.luminate.bootstrap.environment_bootstrapper import EnvironmentBootstrapper
|
4
6
|
from orionis.luminate.patterns.singleton import SingletonMeta
|
5
7
|
|
6
8
|
class Application(metaclass=SingletonMeta):
|
@@ -22,7 +24,10 @@ class Application(metaclass=SingletonMeta):
|
|
22
24
|
commands_bootstrapper_key = self.container.singleton(CommandsBootstrapper)
|
23
25
|
commands_bootstrapper: CommandsBootstrapper = self.container.make(commands_bootstrapper_key)
|
24
26
|
self._commands = commands_bootstrapper.get()
|
25
|
-
|
27
|
+
|
28
|
+
environment_bootstrapper_key = self.container.singleton(EnvironmentBootstrapper)
|
29
|
+
environment_bootstrapper: EnvironmentBootstrapper = self.container.make(environment_bootstrapper_key)
|
30
|
+
self._environment = environment_bootstrapper.get()
|
26
31
|
|
27
32
|
def isBooted(self):
|
28
33
|
return True
|
@@ -0,0 +1,138 @@
|
|
1
|
+
import ast
|
2
|
+
import os
|
3
|
+
from pathlib import Path
|
4
|
+
from typing import Dict
|
5
|
+
from dotenv import dotenv_values
|
6
|
+
from orionis.contracts.bootstrap.i_environment_bootstrapper import IEnvironmentBootstrapper
|
7
|
+
from orionis.luminate.bootstrap.exception_bootstrapper import BootstrapRuntimeError
|
8
|
+
|
9
|
+
class EnvironmentBootstrapper(IEnvironmentBootstrapper):
|
10
|
+
"""
|
11
|
+
A class responsible for loading and managing environment variables from a `.env` file.
|
12
|
+
|
13
|
+
This class implements the `IEnvironment` interface and provides functionality to
|
14
|
+
automatically load environment variables from a `.env` file located in the current
|
15
|
+
working directory. If the file does not exist, it creates it.
|
16
|
+
|
17
|
+
Attributes
|
18
|
+
----------
|
19
|
+
_environment_vars : Dict[str, str]
|
20
|
+
A dictionary to store the loaded environment variables.
|
21
|
+
path : Path
|
22
|
+
The path to the `.env` file.
|
23
|
+
|
24
|
+
Methods
|
25
|
+
-------
|
26
|
+
__init__()
|
27
|
+
Initializes the `EnvironmentBootstrapper` and triggers the autoload process.
|
28
|
+
_autoload()
|
29
|
+
Loads environment variables from the `.env` file or creates the file if it does not exist.
|
30
|
+
"""
|
31
|
+
|
32
|
+
def __init__(self) -> None:
|
33
|
+
"""
|
34
|
+
Initializes the `EnvironmentBootstrapper` and triggers the autoload process.
|
35
|
+
|
36
|
+
The `_environment_vars` dictionary is initialized to store environment variables,
|
37
|
+
and the `_autoload` method is called to load variables from the `.env` file.
|
38
|
+
"""
|
39
|
+
self._environment_vars: Dict[str, str] = {}
|
40
|
+
self._autoload()
|
41
|
+
|
42
|
+
def _autoload(self) -> None:
|
43
|
+
"""
|
44
|
+
Loads environment variables from the `.env` file or creates the file if it does not exist.
|
45
|
+
|
46
|
+
This method checks if the `.env` file exists in the current working directory.
|
47
|
+
If the file does not exist, it creates an empty `.env` file. If the file exists,
|
48
|
+
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
|
+
"""
|
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
|
111
|
+
|
112
|
+
def get(self, key: str = None) -> str:
|
113
|
+
"""
|
114
|
+
Retrieves the value of an environment variable by its key.
|
115
|
+
|
116
|
+
Parameters
|
117
|
+
----------
|
118
|
+
key : str
|
119
|
+
The key of the environment variable to retrieve.
|
120
|
+
|
121
|
+
Returns
|
122
|
+
-------
|
123
|
+
str
|
124
|
+
The value of the environment variable.
|
125
|
+
|
126
|
+
Raises
|
127
|
+
------
|
128
|
+
KeyError
|
129
|
+
If the environment variable does not exist.
|
130
|
+
"""
|
131
|
+
|
132
|
+
if not key:
|
133
|
+
return self._environment_vars
|
134
|
+
|
135
|
+
if key not in self._environment_vars:
|
136
|
+
raise KeyError(f"Environment variable {key} not found")
|
137
|
+
|
138
|
+
return self._environment_vars[key]
|
@@ -1,67 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
from pathlib import Path
|
3
|
-
from typing import Dict
|
4
|
-
from dotenv import dotenv_values
|
5
|
-
from orionis.contracts.bootstrap.i_environment_bootstrapper import IEnvironmentBootstrapper
|
6
|
-
from orionis.luminate.bootstrap.exception_bootstrapper import BootstrapRuntimeError
|
7
|
-
|
8
|
-
class EnvironmentBootstrapper(IEnvironmentBootstrapper):
|
9
|
-
"""
|
10
|
-
A class responsible for loading and managing environment variables from a `.env` file.
|
11
|
-
|
12
|
-
This class implements the `IEnvironment` interface and provides functionality to
|
13
|
-
automatically load environment variables from a `.env` file located in the current
|
14
|
-
working directory. If the file does not exist, it creates it.
|
15
|
-
|
16
|
-
Attributes
|
17
|
-
----------
|
18
|
-
_environment_vars : Dict[str, str]
|
19
|
-
A dictionary to store the loaded environment variables.
|
20
|
-
path : Path
|
21
|
-
The path to the `.env` file.
|
22
|
-
|
23
|
-
Methods
|
24
|
-
-------
|
25
|
-
__init__()
|
26
|
-
Initializes the `EnvironmentBootstrapper` and triggers the autoload process.
|
27
|
-
_autoload()
|
28
|
-
Loads environment variables from the `.env` file or creates the file if it does not exist.
|
29
|
-
"""
|
30
|
-
|
31
|
-
def __init__(self) -> None:
|
32
|
-
"""
|
33
|
-
Initializes the `EnvironmentBootstrapper` and triggers the autoload process.
|
34
|
-
|
35
|
-
The `_environment_vars` dictionary is initialized to store environment variables,
|
36
|
-
and the `_autoload` method is called to load variables from the `.env` file.
|
37
|
-
"""
|
38
|
-
self._environment_vars: Dict[str, str] = {}
|
39
|
-
self._autoload()
|
40
|
-
|
41
|
-
def _autoload(self) -> None:
|
42
|
-
"""
|
43
|
-
Loads environment variables from the `.env` file or creates the file if it does not exist.
|
44
|
-
|
45
|
-
This method checks if the `.env` file exists in the current working directory.
|
46
|
-
If the file does not exist, it creates an empty `.env` file. If the file exists,
|
47
|
-
it loads the environment variables into the `_environment_vars` dictionary.
|
48
|
-
|
49
|
-
Raises
|
50
|
-
------
|
51
|
-
PermissionError
|
52
|
-
If the `.env` file cannot be created or read due to insufficient permissions.
|
53
|
-
"""
|
54
|
-
# Set the path to the `.env` file
|
55
|
-
path: Path = Path(os.getcwd()) / ".env"
|
56
|
-
|
57
|
-
# Create the `.env` file if it does not exist
|
58
|
-
if not path.exists():
|
59
|
-
try:
|
60
|
-
path.touch() # Create an empty `.env` file if it does not exist
|
61
|
-
except PermissionError as e:
|
62
|
-
raise PermissionError(f"Cannot create `.env` file at {path}: {str(e)}")
|
63
|
-
|
64
|
-
try:
|
65
|
-
self._environment_vars = dotenv_values(path) # Load environment variables
|
66
|
-
except Exception as e:
|
67
|
-
raise BootstrapRuntimeError(f"Error loading environment variables from {path}: {str(e)}")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{orionis-0.59.0 → orionis-0.62.0}/orionis/contracts/facades/environment/i_environment_facade.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/facades/environment/environment_facade.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{orionis-0.59.0 → orionis-0.62.0}/orionis/luminate/providers/config/config_service_provider.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|