orionis 0.50.0__py3-none-any.whl → 0.52.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +1,74 @@
1
-
2
1
  from abc import ABC, abstractmethod
3
2
 
4
3
  class IEnv(ABC):
5
- """
6
- A facade class for accessing environment variables.
7
4
 
8
- This class provides a static method to retrieve environment variables
9
- stored in the application context. It implements the `IEnv` interface.
5
+ @abstractmethod
6
+ def _initialize(self, path: str = None):
7
+ """
8
+ Initializes the instance by setting the path to the .env file.
9
+ If no path is provided, defaults to a `.env` file in the current directory.
10
10
 
11
- Methods
12
- -------
13
- get(key: str, default=None) -> str
14
- Retrieves the value of an environment variable.
15
- """
11
+ Parameters
12
+ ----------
13
+ path : str, optional
14
+ Path to the .env file. Defaults to None.
15
+ """
16
+ pass
16
17
 
17
18
  @abstractmethod
18
- def get(key: str, default=None) -> str:
19
+ def get(self, key: str, default=None) -> str:
19
20
  """
20
- Retrieves the value of an environment variable.
21
-
22
- This method provides a convenient way to access environment variables
23
- stored in the application context. If the variable does not exist, it
24
- returns the specified default value.
21
+ Retrieves the value of an environment variable from the .env file
22
+ or from system environment variables if not found.
25
23
 
26
24
  Parameters
27
25
  ----------
28
26
  key : str
29
- The name of the environment variable to retrieve.
30
- default : Any, optional
31
- The default value to return if the environment variable does not exist.
32
- Defaults to None.
27
+ The key of the environment variable.
28
+ default : optional
29
+ Default value if the key does not exist. Defaults to None.
33
30
 
34
31
  Returns
35
32
  -------
36
33
  str
37
- The value of the environment variable, or the default value if the variable
38
- does not exist.
34
+ The value of the environment variable or the default value.
35
+ """
36
+ pass
37
+
38
+ @abstractmethod
39
+ def set(self, key: str, value: str) -> None:
40
+ """
41
+ Sets the value of an environment variable in the .env file.
42
+
43
+ Parameters
44
+ ----------
45
+ key : str
46
+ The key of the environment variable.
47
+ value : str
48
+ The value to set.
49
+ """
50
+ pass
51
+
52
+ @abstractmethod
53
+ def unset(self, key: str) -> None:
54
+ """
55
+ Removes an environment variable from the .env file.
56
+
57
+ Parameters
58
+ ----------
59
+ key : str
60
+ The key of the environment variable to remove.
61
+ """
62
+ pass
63
+
64
+ @abstractmethod
65
+ def all(self) -> dict:
66
+ """
67
+ Retrieves all environment variable values from the .env file.
68
+
69
+ Returns
70
+ -------
71
+ dict
72
+ A dictionary of all environment variables and their values.
39
73
  """
40
74
  pass
orionis/framework.py CHANGED
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.50.0"
8
+ VERSION = "0.52.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
orionis/luminate/app.py CHANGED
@@ -1,103 +1,19 @@
1
1
  import traceback
2
2
  from orionis.luminate.container.container import Container
3
- from orionis.luminate.bootstrap.config_bootstrapper import Bootstrapper as BootstrapperConfig
3
+ from orionis.luminate.bootstrap.config_bootstrapper import ConfigBootstrapper
4
4
  from orionis.luminate.patterns.singleton import SingletonMeta
5
5
 
6
6
  class Application(metaclass=SingletonMeta):
7
- """
8
- The main service container for the Orionis Framework, ensuring persistent dependency resolution.
9
-
10
- This class acts as a singleton service container, similar to Laravel's Application class.
11
- It maintains service bindings, ensures proper initialization, and prevents unnecessary re-instantiation.
12
-
13
- Attributes
14
- ----------
15
- container : Container
16
- The IoC container that holds all service bindings.
17
- booted : bool
18
- Indicates whether the application has been initialized.
19
- error_info : tuple or None
20
- Stores error information if an exception occurs during boot.
21
-
22
- Methods
23
- -------
24
- boot()
25
- Initializes the application and registers all necessary dependencies.
26
- isBooted()
27
- Checks if the application is currently running.
28
- getError()
29
- Retrieves stored error information, if any.
30
- """
31
7
 
32
8
  def __init__(self):
33
- """Initializes the application with an empty dependency container."""
34
9
  self.container = Container()
35
- self.booted = False
36
- self.error_info = None
37
-
38
- self._config = {}
39
-
40
- def register(self):
41
- """
42
- Registers all necessary service bindings with the application container.
43
-
44
- This method is intended to be overridden by the user to define custom service bindings.
45
- """
46
- pass
47
-
48
- def boot(self):
49
- """
50
- Boots the application and registers necessary dependencies.
51
-
52
- This method ensures that all required services are bound to the container and instantiated.
53
- If the application is already booted, it returns immediately.
10
+ self.container.instance(self.container)
11
+ self._bootstraping()
54
12
 
55
- Returns
56
- -------
57
- Application
58
- The current instance of the application.
59
-
60
- Raises
61
- ------
62
- Exception
63
- If an error occurs during the boot process.
64
- """
65
- if self.booted:
66
- return self
67
-
68
- try:
69
- # Config Bootstrapper and retrieve application configuration
70
- boot_config = self.container.singleton(BootstrapperConfig)
71
- app_config = self.container.make(boot_config)
72
- self._config = app_config.get()
73
-
74
- self.booted = True
75
- return self
76
-
77
- except Exception as e:
78
- # Capture and store exception details
79
- self.error_info = (e, traceback.format_exc())
80
- raise
13
+ def _bootstraping(self):
14
+ config_bootstrapper = self.container.singleton(ConfigBootstrapper)
15
+ config = self.container.make(config_bootstrapper)
16
+ print(config)
81
17
 
82
18
  def isBooted(self):
83
- """
84
- Checks if the application has been successfully initialized.
85
-
86
- Returns
87
- -------
88
- bool
89
- True if the application has been booted, False otherwise.
90
- """
91
- return self.booted
92
-
93
- def getError(self):
94
- """
95
- Retrieves the last stored error details.
96
-
97
- Returns
98
- -------
99
- tuple or None
100
- A tuple containing the exception instance and its formatted traceback if an error occurred;
101
- otherwise, None.
102
- """
103
- return self.error_info
19
+ return True
@@ -1,5 +1,8 @@
1
+ import os
2
+ import threading
3
+ from pathlib import Path
4
+ from dotenv import set_key, unset_key, dotenv_values
1
5
  from orionis.contracts.facades.environment.i_environment_facade import IEnv
2
- from orionis.luminate.app_context import AppContext
3
6
 
4
7
  def env(key: str, default=None) -> str:
5
8
  """
@@ -23,46 +26,111 @@ def env(key: str, default=None) -> str:
23
26
  The value of the environment variable, or the default value if the variable
24
27
  does not exist.
25
28
  """
26
- with AppContext() as app:
27
- env : dict = app._environment_vars
28
- return env.get(key, default)
29
+ return Environment().get(key, default)
29
30
 
30
- class Env(IEnv):
31
+ class Environment(IEnv):
32
+ """
33
+ A thread-safe singleton class that manages environment variables from a .env file.
31
34
  """
32
- A facade class for accessing environment variables.
33
35
 
34
- This class provides a static method to retrieve environment variables
35
- stored in the application context. It implements the `IEnv` interface.
36
+ _instance = None
37
+ _lock = threading.Lock()
36
38
 
37
- Methods
38
- -------
39
- get(key: str, default=None) -> str
40
- Retrieves the value of an environment variable.
41
- """
39
+ def __new__(cls, path: str = None):
40
+ """
41
+ Override the __new__ method to ensure only one instance of the class is created.
42
+
43
+ Parameters
44
+ ----------
45
+ path : str, optional
46
+ The path to the .env file. Defaults to None.
42
47
 
43
- @staticmethod
44
- def get(key: str, default=None) -> str:
48
+ Returns
49
+ -------
50
+ Environment
51
+ The singleton instance of the Environment class.
45
52
  """
46
- Retrieves the value of an environment variable.
53
+ # Use the lock to ensure thread-safe instantiation
54
+ with cls._lock:
55
+ if cls._instance is None:
56
+ cls._instance = super().__new__(cls)
57
+ cls._instance._initialize(path)
58
+ return cls._instance
47
59
 
48
- This method provides a convenient way to access environment variables
49
- stored in the application context. If the variable does not exist, it
50
- returns the specified default value.
60
+ def _initialize(self, path: str = None):
61
+ """
62
+ Initializes the instance by setting the path to the .env file.
63
+ If no path is provided, defaults to a `.env` file in the current directory.
64
+
65
+ Parameters
66
+ ----------
67
+ path : str, optional
68
+ Path to the .env file. Defaults to None.
69
+ """
70
+ # Set the path to the .env file
71
+ self.path = Path(path) if path else Path(os.getcwd()) / ".env"
72
+
73
+ # Create the .env file if it does not exist
74
+ if not self.path.exists():
75
+ self.path.touch()
76
+
77
+ def get(self, key: str, default=None) -> str:
78
+ """
79
+ Retrieves the value of an environment variable from the .env file
80
+ or from system environment variables if not found.
51
81
 
52
82
  Parameters
53
83
  ----------
54
84
  key : str
55
- The name of the environment variable to retrieve.
56
- default : Any, optional
57
- The default value to return if the environment variable does not exist.
58
- Defaults to None.
85
+ The key of the environment variable.
86
+ default : optional
87
+ Default value if the key does not exist. Defaults to None.
59
88
 
60
89
  Returns
61
90
  -------
62
91
  str
63
- The value of the environment variable, or the default value if the variable
64
- does not exist.
92
+ The value of the environment variable or the default value.
93
+ """
94
+ # Get the value from the .env file
95
+ value = dotenv_values(self.path).get(key)
96
+
97
+ # Return the value or the default value
98
+ return value if value is not None else os.getenv(key, default)
99
+
100
+ def set(self, key: str, value: str) -> None:
101
+ """
102
+ Sets the value of an environment variable in the .env file.
103
+
104
+ Parameters
105
+ ----------
106
+ key : str
107
+ The key of the environment variable.
108
+ value : str
109
+ The value to set.
110
+ """
111
+ # Set the value in the .env file
112
+ set_key(str(self.path), key, value)
113
+
114
+ def unset(self, key: str) -> None:
115
+ """
116
+ Removes an environment variable from the .env file.
117
+
118
+ Parameters
119
+ ----------
120
+ key : str
121
+ The key of the environment variable to remove.
122
+ """
123
+ # Remove the key from the .env file
124
+ unset_key(str(self.path), key)
125
+
126
+ def all(self) -> dict:
127
+ """
128
+ Retrieves all environment variable values from the .env file.
129
+
130
+ Returns
131
+ -------
132
+ dict
133
+ A dictionary of all environment variables and their values.
65
134
  """
66
- with AppContext() as app:
67
- env : dict = app._environment_vars
68
- return env.get(key, default)
135
+ # Return all environment variables
136
+ return dotenv_values(self.path)
@@ -1,6 +1,5 @@
1
1
  import os
2
2
  from orionis.contracts.facades.files.i_path_facade import IPath
3
- from orionis.luminate.app_context import AppContext
4
3
  from orionis.luminate.services.files.path_service import PathService
5
4
 
6
5
  class Path(IPath):
@@ -66,9 +65,7 @@ class Path(IPath):
66
65
  route = os.path.normpath(route)
67
66
 
68
67
  # Obtain the path service from the container
69
- with AppContext() as app:
70
- path_service : PathService = app.container.make(PathService)
71
- return path_service.resolve(route)
68
+ PathService().resolve(route)
72
69
 
73
70
  @staticmethod
74
71
  def app(file: str = None):
@@ -1,10 +1,11 @@
1
1
  import os
2
+ import threading
2
3
  from pathlib import Path
3
4
  from orionis.contracts.services.files.i_path_service import IPathService
4
5
 
5
6
  class PathService(IPathService):
6
7
  """
7
- A service class for resolving and validating absolute paths.
8
+ A thread-safe singleton class for resolving and validating absolute paths.
8
9
 
9
10
  This class resolves the absolute path for a given relative directory or file path
10
11
  based on the script's execution directory. It ensures that the requested path is valid
@@ -12,29 +13,37 @@ class PathService(IPathService):
12
13
 
13
14
  Attributes
14
15
  ----------
16
+ base_path : Path
17
+ The base path (current working directory) used for resolving relative paths.
15
18
  route : str
16
19
  The resolved absolute path to the directory or file.
17
-
18
- Methods
19
- -------
20
- __init__(route: str)
21
- Initializes the `PathService` and resolves the absolute path.
22
- resolve() -> str
23
- Returns the resolved absolute path as a string.
24
- __str__() -> str
25
- Returns the resolved absolute path as a string (dunder method).
26
20
  """
27
21
 
28
- def __init__(self) -> None:
22
+ _instance = None
23
+ _lock = threading.Lock()
24
+
25
+ def __new__(cls):
26
+ """
27
+ Override the __new__ method to ensure only one instance of the class is created.
28
+
29
+ Returns
30
+ -------
31
+ PathService
32
+ The singleton instance of the PathService class.
29
33
  """
30
- Initializes the `PathService` and resolves the absolute path for a given relative path.
34
+ # Use the lock to ensure thread-safe instantiation
35
+ with cls._lock:
36
+ if cls._instance is None:
37
+ cls._instance = super().__new__(cls)
38
+ cls._instance._initialize()
39
+ return cls._instance
31
40
 
32
- The path is resolved relative to the script's execution directory. It validates
33
- that the resolved path exists and is either a directory or a file.
41
+ def _initialize(self):
42
+ """
43
+ Initializes the instance by setting the base path to the current working directory.
34
44
  """
35
45
  self.base_path = Path(os.getcwd())
36
46
 
37
-
38
47
  def resolve(self, route: str) -> str:
39
48
  """
40
49
  Resolves and returns the absolute path as a string.
@@ -58,7 +67,6 @@ class PathService(IPathService):
58
67
  ValueError
59
68
  If the resolved path does not exist or is neither a directory nor a file.
60
69
  """
61
-
62
70
  # Combine base path with the relative route
63
71
  real_path = (self.base_path / route).resolve()
64
72
 
@@ -68,4 +76,16 @@ class PathService(IPathService):
68
76
  if not (real_path.is_dir() or real_path.is_file()):
69
77
  raise ValueError(f"The requested path is neither a directory nor a file: {real_path}")
70
78
 
71
- self.route = str(real_path)
79
+ self.route = str(real_path)
80
+ return self.route
81
+
82
+ def __str__(self) -> str:
83
+ """
84
+ Returns the resolved absolute path as a string (dunder method).
85
+
86
+ Returns
87
+ -------
88
+ str
89
+ The absolute path to the directory or file.
90
+ """
91
+ return self.route
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.50.0
3
+ Version: 0.52.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -1,6 +1,6 @@
1
1
  orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  orionis/cli_manager.py,sha256=0bM-hABXJSoPGuvEgnqeaj9qcLP8VjTQ3z9Mb0TSEUI,1381
3
- orionis/framework.py,sha256=zaQxtEh5l2kkr_9LZpo4I9w6-4OvJ_uehswE6IAwTks,1386
3
+ orionis/framework.py,sha256=kgccYFILTuryLUPusOkCYv4NMaL18wseDFViMTgTJ2Q,1386
4
4
  orionis/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  orionis/contracts/bootstrap/i_command_bootstrapper.py,sha256=kdabnjTRXcab0Kelcst8MhuJ_iP0XX8taChMupwzF1M,1901
6
6
  orionis/contracts/bootstrap/i_config_bootstrapper.py,sha256=x38bXXX49ASm5yZ0O6vwssmtiLMsF-fkxFcq-Cqf5GM,3480
@@ -26,7 +26,7 @@ orionis/contracts/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
26
26
  orionis/contracts/facades/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  orionis/contracts/facades/config/i_config_facade.py,sha256=Yzc0mB4W9XF8cZTdTO78AKUiyGaiShl1k8nJiecvKTc,970
28
28
  orionis/contracts/facades/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- orionis/contracts/facades/environment/i_environment_facade.py,sha256=CFJ8mbPZceblufxzRJ3kMweRuG4KkJyx5JzAqQ91FXY,1221
29
+ orionis/contracts/facades/environment/i_environment_facade.py,sha256=-xyYYqC1DrkQ751d2qTsGNNgnvs_idn1v4TYZ4X7Z34,1944
30
30
  orionis/contracts/facades/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  orionis/contracts/facades/files/i_path_facade.py,sha256=-6OWYFsXmQ2vOBlp6uBwN0TnwTB-otaBEJiYO7ZKVoQ,4497
32
32
  orionis/contracts/facades/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -46,7 +46,6 @@ orionis/contracts/services/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
46
46
  orionis/contracts/services/files/i_path_service.py,sha256=Le5sax8c_PjUyb5Hg7AVQALGjxlym5cc6OSPvGCKBKk,866
47
47
  orionis/contracts/services/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
48
  orionis/contracts/services/log/i_log_service.py,sha256=1RD3u-a5ZDMbg7AYE8y2SW8QNRybAU3De0mEA0dAeNo,2167
49
- orionis/contracts/support/i_environment.py,sha256=sng4uN4D74MGy71J45m1oRmkKpNWLn79OEuOsf9ZuWQ,1952
50
49
  orionis/contracts/support/i_exception_to_dict.py,sha256=LZpbCNDYQJs3j2mIM-NRFl0IfA8I0GFHExgRSO6K2FQ,780
51
50
  orionis/contracts/support/i_reflection.py,sha256=Ht5_FsFbCb-APRXX3HdsfKl3cDZU8DyXGXPWKTn05uQ,8429
52
51
  orionis/contracts/support/i_std.py,sha256=IihREHnJ_D2LqsrwtnGsIRYr0UsJsQezYPSPO6UaBQ4,992
@@ -55,7 +54,7 @@ orionis/installer/installer_manager.py,sha256=Hb6T0bmSl39T30maY-nUWkrLhG77JdrKe4
55
54
  orionis/installer/installer_output.py,sha256=LeKxzuXpnHOKbKpUtx3tMGkCi2bGcPV1VNnfBxwfxUU,7161
56
55
  orionis/installer/installer_setup.py,sha256=c2HtVklSa-2_-YVonc7fwtoK-RTDqBS2Ybvbekgfqtc,6970
57
56
  orionis/luminate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
- orionis/luminate/app.py,sha256=VUJMl5G3UAY6DaG3oqS5a9J2mBGH0DTlLjssHub4fNw,3310
57
+ orionis/luminate/app.py,sha256=oMrrKAs578rgtq-X1KQxpMu2yfuAJMgE2iuFphc0wQU,647
59
58
  orionis/luminate/app_context.py,sha256=XREVkOHU6aP8UB2daA2QbFcOCB8HRmcGXjVbrlW1AHQ,1827
60
59
  orionis/luminate/bootstrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
60
  orionis/luminate/bootstrap/command_bootstrapper.py,sha256=fXOvdeyNoB2oN_o1YzhWMbjLa3Nubgwo5QaTNAfm9N4,6297
@@ -69,7 +68,6 @@ orionis/luminate/config/cache.py,sha256=nBKmDFDb91sbBriEsVLjMhrNb__j7YsRzZGQRDdA
69
68
  orionis/luminate/config/cors.py,sha256=zWKUylPiaUzGXTJM3eLmwY0HcAD7iOLp9QiAoTyAL08,2275
70
69
  orionis/luminate/config/database.py,sha256=oj-FQWtbwIYrJAQktSGBl96EZu78fr6IBcQxHbWDVBM,5619
71
70
  orionis/luminate/config/filesystems.py,sha256=fAn4Wx6naIb8E4U2TXJhVnx0Ipxpxc_Ee2w_FWfwlHI,2444
72
- orionis/luminate/config/helpers.py,sha256=qkWDmrfjCxaSJ3P8hJlJ32xSPnKyOnJhmUn2jigPtx0,585
73
71
  orionis/luminate/config/logging.py,sha256=H110K6LyTCNgxZPqiGGn0z8FZ2I6kW5ZKfsVhoWB4KM,2832
74
72
  orionis/luminate/config/mail.py,sha256=3iYXG72bXiVns4sEPZ_A3-cGcFjGEGDXkuLKkk-hKtY,2102
75
73
  orionis/luminate/config/queue.py,sha256=DYjP5zD09ISsIX117wtOfjiG_iQrcrPoQVeeftmuO3c,1739
@@ -103,9 +101,9 @@ orionis/luminate/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
103
101
  orionis/luminate/facades/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
104
102
  orionis/luminate/facades/config/config_facade.py,sha256=GLQ6JiD2dB7WLyhUZ4SGBSNo7VuwHpX_QrrQcvjoAi8,1429
105
103
  orionis/luminate/facades/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
106
- orionis/luminate/facades/environment/environment_facade.py,sha256=AgLeECJU8N2qcs6JAyGkQTF1Amq9co0Ser0SZerjx74,2236
104
+ orionis/luminate/facades/environment/environment_facade.py,sha256=QPywyoqONbUZZhNPzfoNpMXgKq3V0Rr6LsIBK57zpcY,4207
107
105
  orionis/luminate/facades/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
- orionis/luminate/facades/files/path_facade.py,sha256=9cEi66nwW4RD8Xc8cTa2RE9YfqW1-fbD4HXPfwce6bE,9159
106
+ orionis/luminate/facades/files/path_facade.py,sha256=uWU8_-iaMGBWuVxbk_MoTm0FVFq25F_ub-ObvrtceHg,8987
109
107
  orionis/luminate/facades/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
110
108
  orionis/luminate/facades/log/log_facade.py,sha256=r8D9T9MoHriq9Ro7vkrmoZUt774Go5Z9vbZh-ZRgVB4,2729
111
109
  orionis/luminate/facades/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -117,19 +115,16 @@ orionis/luminate/pipelines/cli_pipeline.py,sha256=xpdwxArZrYqaeo4h375RQwY329V14S
117
115
  orionis/luminate/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
118
116
  orionis/luminate/providers/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
119
117
  orionis/luminate/providers/config/config_service_provider.py,sha256=B72XEIzbiFFojB3c361QFTVz3kuM9HEUHaW-whMgytw,946
120
- orionis/luminate/providers/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
121
- orionis/luminate/providers/files/path_service_provider.py,sha256=1FD87NxNogv0LFjOzZ7ts9b6JLh8HYVjcqm2Tk2oxsE,940
122
118
  orionis/luminate/providers/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
119
  orionis/luminate/providers/log/log_service_provider.py,sha256=ROvuiEaUAWN-KMZnW3CKoJMgPR8kP37kLB5y1ug03Jg,942
124
120
  orionis/luminate/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
125
121
  orionis/luminate/services/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
126
122
  orionis/luminate/services/config/config_service.py,sha256=TZa3WZtDKEW6p0bMktzMXn85cOQy-q21myiYu3rZA34,2147
127
123
  orionis/luminate/services/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
- orionis/luminate/services/files/path_service.py,sha256=ttsa7wmw1Lm9eDJdXxUY4ZJYhDtpaPrGJgrTGNu9L3I,2519
124
+ orionis/luminate/services/files/path_service.py,sha256=opLl1k0QLPv9u9GCKENyRsLKhupM_0BDjXE_elk47EU,3039
129
125
  orionis/luminate/services/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
130
126
  orionis/luminate/services/log/log_service.py,sha256=OAqxr1I6GgylpuY6PXqXjAF1CXQaxzLp6bH3qnY5-AQ,5261
131
127
  orionis/luminate/support/dot_dict.py,sha256=FVHfBuAGTTVMjNG01Fix645fRNKKUMmNx61pYkxPL5c,1253
132
- orionis/luminate/support/environment.py,sha256=BkjZstF7TwRA13al20rqz-n5hcsDd6eypnfFHk0_IME,2973
133
128
  orionis/luminate/support/exception_to_dict.py,sha256=jpQ-c7ud1JLm8dTWbvMT1dI-rL3yTB2P8VxNscAX71k,2098
134
129
  orionis/luminate/support/reflection.py,sha256=VYpluTQJ0W_m6jYQ9_L02sYFrk2wlLYtLY2yp9rZMKA,11944
135
130
  orionis/luminate/support/std.py,sha256=pOdpQBOxVAcS8GdkOYpyDKGVpICRd8IN8CE63q6WjGk,1383
@@ -149,9 +144,9 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
149
144
  tests/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
150
145
  tests/tools/class_example.py,sha256=dIPD997Y15n6WmKhWoOFSwEldRm9MdOHTZZ49eF1p3c,1056
151
146
  tests/tools/test_reflection.py,sha256=bhLQ7VGVod4B8sv-rW9AjnOumvaBVsoxieA3sdoM2yM,5244
152
- orionis-0.50.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
153
- orionis-0.50.0.dist-info/METADATA,sha256=xd2l6Xv_UtPy6wZ3sHYEOLKlf5DmdhTXrQLU8VEhf50,2978
154
- orionis-0.50.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
155
- orionis-0.50.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
156
- orionis-0.50.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
157
- orionis-0.50.0.dist-info/RECORD,,
147
+ orionis-0.52.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
148
+ orionis-0.52.0.dist-info/METADATA,sha256=FPzp0hzHmgvz8wcKUdmkVdxFdkRbt8JzWkDyxGNbR5U,2978
149
+ orionis-0.52.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
150
+ orionis-0.52.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
151
+ orionis-0.52.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
152
+ orionis-0.52.0.dist-info/RECORD,,
@@ -1,74 +0,0 @@
1
- from abc import ABC, abstractmethod
2
-
3
- class IEnvironment(ABC):
4
-
5
- @abstractmethod
6
- def _initialize(self, path: str = None):
7
- """
8
- Initializes the instance by setting the path to the .env file.
9
- If no path is provided, defaults to a `.env` file in the current directory.
10
-
11
- Parameters
12
- ----------
13
- path : str, optional
14
- Path to the .env file. Defaults to None.
15
- """
16
- pass
17
-
18
- @abstractmethod
19
- def get(self, key: str, default=None) -> str:
20
- """
21
- Retrieves the value of an environment variable from the .env file
22
- or from system environment variables if not found.
23
-
24
- Parameters
25
- ----------
26
- key : str
27
- The key of the environment variable.
28
- default : optional
29
- Default value if the key does not exist. Defaults to None.
30
-
31
- Returns
32
- -------
33
- str
34
- The value of the environment variable or the default value.
35
- """
36
- pass
37
-
38
- @abstractmethod
39
- def set(self, key: str, value: str) -> None:
40
- """
41
- Sets the value of an environment variable in the .env file.
42
-
43
- Parameters
44
- ----------
45
- key : str
46
- The key of the environment variable.
47
- value : str
48
- The value to set.
49
- """
50
- pass
51
-
52
- @abstractmethod
53
- def unset(self, key: str) -> None:
54
- """
55
- Removes an environment variable from the .env file.
56
-
57
- Parameters
58
- ----------
59
- key : str
60
- The key of the environment variable to remove.
61
- """
62
- pass
63
-
64
- @abstractmethod
65
- def all(self) -> dict:
66
- """
67
- Retrieves all environment variable values from the .env file.
68
-
69
- Returns
70
- -------
71
- dict
72
- A dictionary of all environment variables and their values.
73
- """
74
- pass
@@ -1,20 +0,0 @@
1
- from orionis.luminate.support.environment import Environment
2
-
3
- def env(key: str, default=None) -> str:
4
- """
5
- Retrieves the value of an environment variable from the .env file
6
- or from system environment variables if not found.
7
-
8
- Parameters
9
- ----------
10
- key : str
11
- The key of the environment variable.
12
- default : optional
13
- Default value if the key does not exist. Defaults to None.
14
-
15
- Returns
16
- -------
17
- str
18
- The value of the environment variable or the default value.
19
- """
20
- return Environment().get(key, default)
File without changes
@@ -1,26 +0,0 @@
1
- from orionis.contracts.providers.i_service_provider import IServiceProvider
2
- from orionis.luminate.container.container import Container
3
- from orionis.luminate.services.files.path_service import PathService
4
-
5
- class PathServiceProvider(IServiceProvider):
6
-
7
- def register(self, container: Container) -> None:
8
- """
9
- Registers services or bindings into the given container.
10
-
11
- Args:
12
- container (Container): The container to register services or bindings into.
13
- """
14
- self.key_sp = container.singleton(PathService)
15
-
16
- def boot(self, container: Container) -> None:
17
- """
18
- Boot the service provider.
19
-
20
- This method is intended to be overridden by subclasses to perform
21
- any necessary bootstrapping or initialization tasks.
22
-
23
- Args:
24
- container (Container): The service container instance.
25
- """
26
- container.make(self.key_sp)
@@ -1,99 +0,0 @@
1
- import os
2
- from pathlib import Path
3
- from dotenv import set_key, unset_key, dotenv_values
4
- from orionis.contracts.support.i_environment import IEnvironment
5
- from orionis.luminate.patterns.singleton import SingletonMeta
6
-
7
- class Environment(IEnvironment, metaclass=SingletonMeta):
8
-
9
- def __init__(self, path: str = None):
10
- """
11
- Initialize the environment configuration.
12
-
13
- Args:
14
- path (str, optional): The path to the configuration file. Defaults to None.
15
- """
16
- self._initialize(path)
17
-
18
- def _initialize(self, path: str = None):
19
- """
20
- Initializes the instance by setting the path to the .env file.
21
- If no path is provided, defaults to a `.env` file in the current directory.
22
-
23
- Parameters
24
- ----------
25
- path : str, optional
26
- Path to the .env file. Defaults to None.
27
- """
28
-
29
- # Set the path to the .env file
30
- self.path = Path(path) if path else Path(os.getcwd()) / ".env"
31
-
32
- # Create the .env file if it does not exist
33
- if not self.path.exists():
34
- self.path.touch()
35
-
36
- def get(self, key: str, default=None) -> str:
37
- """
38
- Retrieves the value of an environment variable from the .env file
39
- or from system environment variables if not found.
40
-
41
- Parameters
42
- ----------
43
- key : str
44
- The key of the environment variable.
45
- default : optional
46
- Default value if the key does not exist. Defaults to None.
47
-
48
- Returns
49
- -------
50
- str
51
- The value of the environment variable or the default value.
52
- """
53
-
54
- # Get the value from the .env file
55
- value = dotenv_values(self.path).get(key)
56
-
57
- # Return the value or the default value
58
- return value if value is not None else os.getenv(key, default)
59
-
60
- def set(self, key: str, value: str) -> None:
61
- """
62
- Sets the value of an environment variable in the .env file.
63
-
64
- Parameters
65
- ----------
66
- key : str
67
- The key of the environment variable.
68
- value : str
69
- The value to set.
70
- """
71
-
72
- # Set the value in the .env file
73
- set_key(str(self.path), key, value)
74
-
75
- def unset(self, key: str) -> None:
76
- """
77
- Removes an environment variable from the .env file.
78
-
79
- Parameters
80
- ----------
81
- key : str
82
- The key of the environment variable to remove.
83
- """
84
-
85
- # Remove the key from the .env file
86
- unset_key(str(self.path), key)
87
-
88
- def all(self) -> dict:
89
- """
90
- Retrieves all environment variable values from the .env file.
91
-
92
- Returns
93
- -------
94
- dict
95
- A dictionary of all environment variables and their values.
96
- """
97
-
98
- # Return all environment variables
99
- return dotenv_values(self.path)