orionis 0.68.0__tar.gz → 0.72.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.68.0/orionis.egg-info → orionis-0.72.0}/PKG-INFO +1 -1
- {orionis-0.68.0 → orionis-0.72.0}/orionis/framework.py +1 -1
- orionis-0.72.0/orionis/luminate/app.py +59 -0
- orionis-0.72.0/orionis/luminate/bootstrap/environment_bootstrapper.py +76 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/container/container.py +6 -3
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/environment/environment_service.py +38 -3
- {orionis-0.68.0 → orionis-0.72.0/orionis.egg-info}/PKG-INFO +1 -1
- orionis-0.68.0/orionis/luminate/app.py +0 -33
- orionis-0.68.0/orionis/luminate/bootstrap/environment_bootstrapper.py +0 -138
- {orionis-0.68.0 → orionis-0.72.0}/LICENCE +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/MANIFEST.in +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/README.md +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/cli_manager.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/bootstrap/i_command_bootstrapper.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/bootstrap/i_config_bootstrapper.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/bootstrap/i_environment_bootstrapper.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/config/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/config/i_config.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/base/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/base/i_command.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/i_command_filter.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/i_kernel.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/i_parser.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/i_task_manager.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/output/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/output/i_console.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/output/i_executor.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/output/i_progress_bar.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/tasks/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/console/tasks/i_schedule.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/container/i_container.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/container/i_types.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/config/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/config/i_config_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/environment/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/environment/i_environment_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/files/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/files/i_path_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/log/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/log/i_log_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/tests/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/facades/tests/i_tests_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/installer/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/installer/i_installer_manager.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/installer/i_installer_output.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/installer/i_installer_setup.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/providers/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/providers/i_service_provider.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/config/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/config/i_config_service.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/environment/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/environment/i_environment_service.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/files/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/files/i_path_resolver_service.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/log/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/log/i_log_service.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/support/i_exception_to_dict.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/support/i_reflection.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/support/i_std.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/installer/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/installer/installer_manager.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/installer/installer_output.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/installer/installer_setup.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/app_context.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/bootstrap/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/bootstrap/command_bootstrapper.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/bootstrap/config_bootstrapper.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/bootstrap/exception_bootstrapper.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/bootstrap/service_providers_bootstrapper.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/app.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/auth.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/cache.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/cors.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/database.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/filesystems.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/logging.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/mail.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/queue.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/config/session.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/base/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/base/command.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/command_filter.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/commands/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/commands/cache_clear.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/commands/help.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/commands/schedule_work.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/commands/tests.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/commands/version.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/exceptions/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/exceptions/cli_exception.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/kernel.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/output/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/output/console.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/output/executor.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/output/progress_bar.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/output/styles.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/parser.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/runner.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/tasks/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/console/tasks/scheduler.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/container/exception.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/container/types.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/app.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/config/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/config/config_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/environment/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/environment/environment_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/files/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/files/path_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/log/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/log/log_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/tests/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/facades/tests/tests_facade.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/patterns/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/patterns/singleton.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/pipelines/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/pipelines/cli_pipeline.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/providers/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/providers/config/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/providers/config/config_service_provider.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/providers/environment/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/providers/environment/environment_provider.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/providers/log/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/providers/log/log_service_provider.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/providers/service_provider.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/config/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/config/config_service.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/environment/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/files/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/files/path_resolver_service.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/log/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/log/log_service.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/support/dot_dict.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/support/exception_to_dict.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/support/reflection.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/support/std.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/test/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/test/exception.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/test/unit_test.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/static/ascii/icon.ascii +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/static/ascii/info.ascii +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/static/bg/galaxy.jpg +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/static/favicon/OrionisFrameworkFavicon.png +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/static/logos/OrionisFramework.jpg +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/static/logos/OrionisFramework.png +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/static/logos/OrionisFramework.psd +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/static/logos/OrionisFramework2.png +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis/static/logos/OrionisFramework3.png +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis.egg-info/SOURCES.txt +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis.egg-info/dependency_links.txt +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis.egg-info/entry_points.txt +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis.egg-info/requires.txt +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/orionis.egg-info/top_level.txt +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/setup.cfg +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/setup.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/tests/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/tests/tools/__init__.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/tests/tools/class_example.py +0 -0
- {orionis-0.68.0 → orionis-0.72.0}/tests/tools/test_reflection.py +0 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
from orionis.luminate.container.container import Container
|
2
|
+
from orionis.luminate.bootstrap.config_bootstrapper import ConfigBootstrapper
|
3
|
+
from orionis.luminate.bootstrap.command_bootstrapper import CommandsBootstrapper
|
4
|
+
from orionis.luminate.bootstrap.environment_bootstrapper import EnvironmentBootstrapper
|
5
|
+
from orionis.luminate.patterns.singleton import SingletonMeta
|
6
|
+
from orionis.luminate.providers.environment.environment_provider import EnvironmentProvider
|
7
|
+
|
8
|
+
class Application(metaclass=SingletonMeta):
|
9
|
+
|
10
|
+
def __init__(self, container: Container):
|
11
|
+
|
12
|
+
# Atributos de la clase
|
13
|
+
self._config = {}
|
14
|
+
self._commands = {}
|
15
|
+
self._environment_vars = {}
|
16
|
+
|
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.
|
25
|
+
self._bootstraping()
|
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
|
+
|
37
|
+
def _bootstraping(self):
|
38
|
+
|
39
|
+
# Cargar la configuracion de la aplicacion
|
40
|
+
config_bootstrapper_key = self.container.singleton(ConfigBootstrapper)
|
41
|
+
config_bootstrapper: ConfigBootstrapper = self.container.make(config_bootstrapper_key)
|
42
|
+
self._config = config_bootstrapper.get()
|
43
|
+
|
44
|
+
# Cargar los comandos propios y definidos por el desarrollador
|
45
|
+
commands_bootstrapper_key = self.container.singleton(CommandsBootstrapper)
|
46
|
+
commands_bootstrapper: CommandsBootstrapper = self.container.make(commands_bootstrapper_key)
|
47
|
+
self._commands = commands_bootstrapper.get()
|
48
|
+
|
49
|
+
# Cargar las variables de entorno solo desde el archivo .env (No se carga desde el sistema operativo, por seguridad)
|
50
|
+
environment_bootstrapper_key = self.container.singleton(EnvironmentBootstrapper)
|
51
|
+
environment_bootstrapper: EnvironmentBootstrapper = self.container.make(environment_bootstrapper_key)
|
52
|
+
self._environment_vars = environment_bootstrapper.get()
|
53
|
+
|
54
|
+
def _registerCommands(self):
|
55
|
+
|
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)
|
@@ -0,0 +1,76 @@
|
|
1
|
+
from typing import Dict
|
2
|
+
from orionis.contracts.bootstrap.i_environment_bootstrapper import IEnvironmentBootstrapper
|
3
|
+
from orionis.luminate.facades.app import app
|
4
|
+
from orionis.luminate.services.environment.environment_service import EnvironmentService
|
5
|
+
|
6
|
+
class EnvironmentBootstrapper(IEnvironmentBootstrapper):
|
7
|
+
"""
|
8
|
+
A class responsible for loading and managing environment variables from a `.env` file.
|
9
|
+
|
10
|
+
This class implements the `IEnvironment` interface and provides functionality to
|
11
|
+
automatically load environment variables from a `.env` file located in the current
|
12
|
+
working directory. If the file does not exist, it creates it.
|
13
|
+
|
14
|
+
Attributes
|
15
|
+
----------
|
16
|
+
_environment_vars : Dict[str, str]
|
17
|
+
A dictionary to store the loaded environment variables.
|
18
|
+
path : Path
|
19
|
+
The path to the `.env` file.
|
20
|
+
|
21
|
+
Methods
|
22
|
+
-------
|
23
|
+
__init__()
|
24
|
+
Initializes the `EnvironmentBootstrapper` and triggers the autoload process.
|
25
|
+
_autoload()
|
26
|
+
Loads environment variables from the `.env` file or creates the file if it does not exist.
|
27
|
+
"""
|
28
|
+
|
29
|
+
def __init__(self) -> None:
|
30
|
+
"""
|
31
|
+
Initializes the `EnvironmentBootstrapper` and triggers the autoload process.
|
32
|
+
|
33
|
+
The `_environment_vars` dictionary is initialized to store environment variables,
|
34
|
+
and the `_autoload` method is called to load variables from the `.env` file.
|
35
|
+
"""
|
36
|
+
self._environment_vars: Dict[str, str] = {}
|
37
|
+
self._autoload()
|
38
|
+
|
39
|
+
def _autoload(self) -> None:
|
40
|
+
"""
|
41
|
+
Loads environment variables from the `.env` file or creates the file if it does not exist.
|
42
|
+
|
43
|
+
This method checks if the `.env` file exists in the current working directory.
|
44
|
+
If the file does not exist, it creates an empty `.env` file. If the file exists,
|
45
|
+
it loads the environment variables into the `_environment_vars` dictionary.
|
46
|
+
"""
|
47
|
+
environment_service : EnvironmentService = app(EnvironmentService)
|
48
|
+
self._environment_vars = environment_service.all()
|
49
|
+
|
50
|
+
def get(self, key: str = None) -> str:
|
51
|
+
"""
|
52
|
+
Retrieves the value of an environment variable by its key.
|
53
|
+
|
54
|
+
Parameters
|
55
|
+
----------
|
56
|
+
key : str
|
57
|
+
The key of the environment variable to retrieve.
|
58
|
+
|
59
|
+
Returns
|
60
|
+
-------
|
61
|
+
str
|
62
|
+
The value of the environment variable.
|
63
|
+
|
64
|
+
Raises
|
65
|
+
------
|
66
|
+
KeyError
|
67
|
+
If the environment variable does not exist.
|
68
|
+
"""
|
69
|
+
|
70
|
+
if not key:
|
71
|
+
return self._environment_vars
|
72
|
+
|
73
|
+
if key not in self._environment_vars:
|
74
|
+
raise KeyError(f"Environment variable {key} not found")
|
75
|
+
|
76
|
+
return self._environment_vars[key]
|
@@ -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,
|
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):
|
{orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/services/environment/environment_service.py
RENAMED
@@ -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
|
-
#
|
58
|
-
|
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
|
-
|
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,33 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
from orionis.luminate.container.container import Container
|
3
|
-
from orionis.luminate.bootstrap.config_bootstrapper import ConfigBootstrapper
|
4
|
-
from orionis.luminate.bootstrap.command_bootstrapper import CommandsBootstrapper
|
5
|
-
from orionis.luminate.bootstrap.environment_bootstrapper import EnvironmentBootstrapper
|
6
|
-
from orionis.luminate.patterns.singleton import SingletonMeta
|
7
|
-
|
8
|
-
class Application(metaclass=SingletonMeta):
|
9
|
-
|
10
|
-
def __init__(self):
|
11
|
-
|
12
|
-
self._config = {}
|
13
|
-
self._commands = {}
|
14
|
-
|
15
|
-
self.container = Container()
|
16
|
-
self.container.instance(self.container)
|
17
|
-
self._bootstraping()
|
18
|
-
|
19
|
-
def _bootstraping(self):
|
20
|
-
config_bootstrapper_key = self.container.singleton(ConfigBootstrapper)
|
21
|
-
config_bootstrapper: ConfigBootstrapper = self.container.make(config_bootstrapper_key)
|
22
|
-
self._config = config_bootstrapper.get()
|
23
|
-
|
24
|
-
commands_bootstrapper_key = self.container.singleton(CommandsBootstrapper)
|
25
|
-
commands_bootstrapper: CommandsBootstrapper = self.container.make(commands_bootstrapper_key)
|
26
|
-
self._commands = commands_bootstrapper.get()
|
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()
|
31
|
-
|
32
|
-
def isBooted(self):
|
33
|
-
return True
|
@@ -1,138 +0,0 @@
|
|
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]
|
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.68.0 → orionis-0.72.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
|
{orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/environment/i_environment_service.py
RENAMED
File without changes
|
File without changes
|
{orionis-0.68.0 → orionis-0.72.0}/orionis/contracts/services/files/i_path_resolver_service.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
|
{orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/bootstrap/service_providers_bootstrapper.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
|
{orionis-0.68.0 → orionis-0.72.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.68.0 → orionis-0.72.0}/orionis/luminate/providers/config/config_service_provider.py
RENAMED
File without changes
|
File without changes
|
{orionis-0.68.0 → orionis-0.72.0}/orionis/luminate/providers/environment/environment_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
|
File without changes
|
File without changes
|