orionis 0.435.0__py3-none-any.whl → 0.437.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. orionis/console/contracts/kernel.py +16 -3
  2. orionis/console/dumper/contracts/dump.py +8 -9
  3. orionis/console/dynamic/progress_bar.py +21 -29
  4. orionis/console/output/console.py +12 -0
  5. orionis/container/context/manager.py +27 -17
  6. orionis/container/context/scope.py +8 -7
  7. orionis/container/contracts/service_provider.py +12 -8
  8. orionis/container/providers/service_provider.py +9 -16
  9. orionis/container/resolver/resolver.py +29 -22
  10. orionis/foundation/contracts/application.py +437 -47
  11. orionis/foundation/contracts/config.py +14 -6
  12. orionis/foundation/providers/console_provider.py +16 -15
  13. orionis/foundation/providers/dumper_provider.py +20 -8
  14. orionis/foundation/providers/logger_provider.py +19 -14
  15. orionis/foundation/providers/path_resolver_provider.py +17 -14
  16. orionis/foundation/providers/progress_bar_provider.py +15 -14
  17. orionis/foundation/providers/testing_provider.py +20 -14
  18. orionis/foundation/providers/workers_provider.py +19 -14
  19. orionis/metadata/framework.py +1 -1
  20. orionis/services/asynchrony/contracts/coroutines.py +5 -9
  21. orionis/services/asynchrony/coroutines.py +10 -23
  22. orionis/services/asynchrony/exceptions/exception.py +3 -3
  23. orionis/services/environment/contracts/caster.py +8 -9
  24. orionis/services/environment/contracts/env.py +9 -9
  25. orionis/services/environment/core/dot_env.py +56 -71
  26. orionis/services/environment/dynamic/caster.py +215 -215
  27. orionis/services/environment/enums/__init__.py +5 -0
  28. orionis/services/environment/enums/value_type.py +22 -25
  29. orionis/services/environment/env.py +28 -12
  30. orionis/services/environment/exceptions/exception.py +6 -2
  31. orionis/services/environment/exceptions/value.py +6 -2
  32. orionis/services/environment/helpers/functions.py +5 -3
  33. orionis/services/environment/key/key_generator.py +8 -11
  34. orionis/services/environment/validators/__init__.py +7 -0
  35. orionis/services/environment/validators/key_name.py +5 -5
  36. orionis/services/environment/validators/types.py +29 -9
  37. orionis/services/introspection/abstract/contracts/reflection.py +188 -221
  38. orionis/services/introspection/abstract/reflection.py +311 -178
  39. orionis/services/introspection/callables/contracts/reflection.py +64 -21
  40. orionis/services/introspection/callables/reflection.py +98 -23
  41. orionis/services/introspection/concretes/reflection.py +278 -181
  42. orionis/services/introspection/dependencies/contracts/reflection.py +21 -18
  43. orionis/services/introspection/dependencies/entities/callable_dependencies.py +15 -16
  44. orionis/services/introspection/dependencies/entities/class_dependencies.py +24 -16
  45. orionis/services/introspection/dependencies/entities/known_dependencies.py +19 -13
  46. orionis/services/introspection/dependencies/entities/method_dependencies.py +22 -16
  47. orionis/services/introspection/dependencies/reflection.py +0 -3
  48. orionis/services/introspection/instances/reflection.py +16 -6
  49. orionis/services/log/contracts/log_service.py +4 -0
  50. orionis/services/log/handlers/filename.py +2 -0
  51. orionis/services/paths/contracts/resolver.py +0 -3
  52. orionis/services/paths/resolver.py +0 -3
  53. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/METADATA +1 -1
  54. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/RECORD +59 -59
  55. /orionis/services/introspection/concretes/contracts/{concrete.py → reflection.py} +0 -0
  56. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/WHEEL +0 -0
  57. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/licenses/LICENCE +0 -0
  58. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/top_level.txt +0 -0
  59. {orionis-0.435.0.dist-info → orionis-0.437.0.dist-info}/zip-safe +0 -0
@@ -2,14 +2,27 @@ from abc import ABC, abstractmethod
2
2
 
3
3
  class IKernelCLI(ABC):
4
4
  """
5
- Interface for the Kernel CLI.
5
+ Abstract base class for the Kernel Command Line Interface (CLI).
6
+
7
+ This interface defines the contract for handling command line arguments
8
+ within the kernel's CLI component.
6
9
  """
7
10
 
8
11
  @abstractmethod
9
12
  def handle(self, args: list) -> None:
10
13
  """
11
- Handle the command line arguments.
14
+ Process the provided command line arguments.
15
+
16
+ Parameters
17
+ ----------
18
+ args : list
19
+ List of command line arguments, typically obtained from sys.argv.
12
20
 
13
- :param args: List of command line arguments (e.g., sys.argv).
21
+ Raises
22
+ ------
23
+ NotImplementedError
24
+ If the method is not implemented by a subclass.
14
25
  """
26
+
27
+ # This method must be implemented by subclasses.
15
28
  raise NotImplementedError("This method should be overridden by subclasses.")
@@ -3,33 +3,32 @@ from typing import Any
3
3
 
4
4
  class IDebug(ABC):
5
5
  """
6
- Debugging utility class for enhanced output and inspection of Python objects.
6
+ Abstract base class for debugging utilities that provide enhanced output and inspection of Python objects.
7
7
 
8
- This class provides methods for dumping and inspecting data in various formats,
9
- including plain text, JSON, and tabular representations. It also supports
10
- rendering nested structures with recursion handling and customizable indentation.
8
+ This class defines the interface for dumping and inspecting data in various formats,
9
+ supporting features such as recursion handling and customizable indentation.
11
10
  """
12
11
 
13
12
  @abstractmethod
14
13
  def dd(self, *args: Any) -> None:
15
14
  """
16
- Dumps the provided arguments to the output and exits the program.
15
+ Dump the provided arguments to the output and terminate the program.
17
16
 
18
17
  Parameters
19
18
  ----------
20
19
  *args : Any
21
- Variable length argument list to be processed and output.
20
+ Variable length argument list to be dumped and displayed.
22
21
  """
23
22
  pass
24
23
 
25
24
  @abstractmethod
26
25
  def dump(self, *args: Any) -> None:
27
26
  """
28
- Dumps the provided arguments for debugging or logging purposes.
27
+ Dump the provided arguments for debugging or logging purposes.
29
28
 
30
29
  Parameters
31
30
  ----------
32
31
  *args : Any
33
- Variable length argument list to be processed and output.
32
+ Variable length argument list to be dumped and displayed.
34
33
  """
35
- pass
34
+ pass
@@ -3,17 +3,14 @@ from orionis.console.dynamic.contracts.progress_bar import IProgressBar
3
3
 
4
4
  class ProgressBar(IProgressBar):
5
5
  """
6
- A console-based progress bar implementation.
7
-
8
- This class provides a simple text-based progress bar that updates
9
- in place without clearing the console.
6
+ Console-based progress bar for tracking and displaying progress.
10
7
 
11
8
  Parameters
12
9
  ----------
13
10
  total : int, optional
14
- The total amount of progress (default is 100).
11
+ The maximum value representing 100% progress. Default is 100.
15
12
  width : int, optional
16
- The width of the progress bar in characters (default is 50).
13
+ The width of the progress bar in characters. Default is 50.
17
14
 
18
15
  Attributes
19
16
  ----------
@@ -23,27 +20,18 @@ class ProgressBar(IProgressBar):
23
20
  The width of the progress bar in characters.
24
21
  progress : int
25
22
  The current progress value.
26
-
27
- Methods
28
- -------
29
- start()
30
- Initializes the progress bar to the starting state.
31
- advance(increment=1)
32
- Advances the progress bar by a given increment.
33
- finish()
34
- Completes the progress bar and moves to a new line.
35
23
  """
36
24
 
37
25
  def __init__(self, total=100, width=50) -> None:
38
26
  """
39
- Constructs all the necessary attributes for the progress bar object.
27
+ Initialize a new ProgressBar instance.
40
28
 
41
29
  Parameters
42
30
  ----------
43
31
  total : int, optional
44
- The total amount of progress (default is 100).
32
+ The maximum value representing 100% progress. Default is 100.
45
33
  width : int, optional
46
- The width of the progress bar in characters (default is 50).
34
+ The width of the progress bar in characters. Default is 50.
47
35
  """
48
36
  self.total = total
49
37
  self.bar_width = width
@@ -51,10 +39,10 @@ class ProgressBar(IProgressBar):
51
39
 
52
40
  def __updateBar(self) -> None:
53
41
  """
54
- Updates the visual representation of the progress bar.
42
+ Update the visual representation of the progress bar in the console.
55
43
 
56
- This method calculates the percentage of progress and updates the
57
- console output accordingly.
44
+ Calculates the percentage of completion and redraws the progress bar
45
+ in place, overwriting the previous output.
58
46
  """
59
47
  percent = self.progress / self.total
60
48
  filled_length = int(self.bar_width * percent)
@@ -66,21 +54,25 @@ class ProgressBar(IProgressBar):
66
54
 
67
55
  def start(self) -> None:
68
56
  """
69
- Initializes the progress bar to the starting state.
57
+ Reset and display the progress bar at the starting state.
70
58
 
71
- This method resets the progress to zero and displays the initial bar.
59
+ Sets the progress to zero and renders the initial progress bar.
72
60
  """
73
61
  self.progress = 0
74
62
  self.__updateBar()
75
63
 
76
64
  def advance(self, increment=1) -> None:
77
65
  """
78
- Advances the progress bar by a specific increment.
66
+ Advance the progress bar by a specified increment.
79
67
 
80
68
  Parameters
81
69
  ----------
82
70
  increment : int, optional
83
- The amount by which the progress should be increased (default is 1).
71
+ The value by which to increase the progress. Default is 1.
72
+
73
+ Notes
74
+ -----
75
+ Progress will not exceed the total value.
84
76
  """
85
77
  self.progress += increment
86
78
  if self.progress > self.total:
@@ -89,12 +81,12 @@ class ProgressBar(IProgressBar):
89
81
 
90
82
  def finish(self) -> None:
91
83
  """
92
- Completes the progress bar.
84
+ Complete the progress bar and move to a new line.
93
85
 
94
- This method sets the progress to its maximum value, updates the bar,
95
- and moves the cursor to a new line for cleaner output.
86
+ Sets progress to the maximum value, updates the bar, and moves the
87
+ cursor to a new line for cleaner output.
96
88
  """
97
89
  self.progress = self.total
98
90
  self.__updateBar()
99
91
  sys.stdout.write("\n")
100
- sys.stdout.flush()
92
+ sys.stdout.flush()
@@ -245,12 +245,20 @@ class Console(IConsole):
245
245
  def clear(self) -> None:
246
246
  """
247
247
  Clears the console screen.
248
+
249
+ Notes
250
+ -----
251
+ Uses the appropriate system command to clear the terminal screen based on the operating system.
248
252
  """
249
253
  os.system('cls' if os.name == 'nt' else 'clear')
250
254
 
251
255
  def clearLine(self) -> None:
252
256
  """
253
257
  Clears the current line in the console.
258
+
259
+ Notes
260
+ -----
261
+ Moves the cursor to the beginning of the line and overwrites it with a space, then returns the cursor to the start.
254
262
  """
255
263
  sys.stdout.write("\r \r")
256
264
  sys.stdout.flush()
@@ -258,6 +266,10 @@ class Console(IConsole):
258
266
  def line(self) -> None:
259
267
  """
260
268
  Prints a horizontal line in the console.
269
+
270
+ Notes
271
+ -----
272
+ Outputs a newline character without advancing to a new line, effectively creating a visual separator.
261
273
  """
262
274
  print("\n", end="")
263
275
 
@@ -2,33 +2,41 @@ from orionis.container.context.scope import ScopedContext
2
2
 
3
3
  class ScopeManager:
4
4
  """
5
- A context manager to manage scoped lifetimes in the container.
5
+ Manages scoped lifetimes for instances within a container context.
6
+
7
+ This class acts as a context manager to handle the storage, retrieval,
8
+ and cleanup of instances associated with a specific scope. It provides
9
+ dictionary-like access to instances and ensures proper scope activation
10
+ and cleanup when used in a context.
6
11
  """
12
+
7
13
  def __init__(self):
8
14
  """
9
- Initialize a new ScopeManager with an empty instances dictionary.
15
+ Initialize the ScopeManager.
16
+
17
+ Initializes an empty dictionary to store scoped instances.
10
18
  """
11
19
  self._instances = {}
12
20
 
13
21
  def __getitem__(self, key):
14
22
  """
15
- Get an instance by key.
23
+ Retrieve an instance associated with the given key.
16
24
 
17
25
  Parameters
18
26
  ----------
19
27
  key : hashable
20
- The key of the instance to retrieve.
28
+ The key identifying the instance.
21
29
 
22
30
  Returns
23
31
  -------
24
32
  object or None
25
- The instance associated with the key or None if not found.
33
+ The instance associated with the key, or None if not found.
26
34
  """
27
35
  return self._instances.get(key)
28
36
 
29
37
  def __setitem__(self, key, value):
30
38
  """
31
- Store an instance by key.
39
+ Store an instance under the specified key.
32
40
 
33
41
  Parameters
34
42
  ----------
@@ -41,12 +49,12 @@ class ScopeManager:
41
49
 
42
50
  def __contains__(self, key):
43
51
  """
44
- Check if a key exists in this scope.
52
+ Check if an instance exists for the given key.
45
53
 
46
54
  Parameters
47
55
  ----------
48
56
  key : hashable
49
- The key to check.
57
+ The key to check for existence.
50
58
 
51
59
  Returns
52
60
  -------
@@ -57,38 +65,40 @@ class ScopeManager:
57
65
 
58
66
  def clear(self):
59
67
  """
60
- Clear all instances from this scope.
68
+ Remove all instances from the current scope.
69
+
70
+ Clears the internal dictionary of all stored instances.
61
71
  """
62
72
  self._instances.clear()
63
73
 
64
74
  def __enter__(self):
65
75
  """
66
- Enter the scope context.
76
+ Activate this scope as the current context.
67
77
 
68
- Sets this scope as the current active scope.
78
+ Sets this ScopeManager as the active scope in ScopedContext.
69
79
 
70
80
  Returns
71
81
  -------
72
82
  ScopeManager
73
- This scope manager instance.
83
+ The current ScopeManager instance.
74
84
  """
75
85
  ScopedContext.setCurrentScope(self)
76
86
  return self
77
87
 
78
88
  def __exit__(self, exc_type, exc_val, exc_tb):
79
89
  """
80
- Exit the scope context.
90
+ Deactivate the current scope and perform cleanup.
81
91
 
82
- Clears this scope and the active scope reference.
92
+ Clears all stored instances and resets the active scope in ScopedContext.
83
93
 
84
94
  Parameters
85
95
  ----------
86
96
  exc_type : type or None
87
- The exception type if an exception was raised, None otherwise.
97
+ The exception type if an exception was raised, otherwise None.
88
98
  exc_val : Exception or None
89
- The exception instance if an exception was raised, None otherwise.
99
+ The exception instance if an exception was raised, otherwise None.
90
100
  exc_tb : traceback or None
91
- The exception traceback if an exception was raised, None otherwise.
101
+ The traceback if an exception was raised, otherwise None.
92
102
  """
93
103
  self.clear()
94
104
  ScopedContext.clear()
@@ -2,8 +2,9 @@ import contextvars
2
2
 
3
3
  class ScopedContext:
4
4
  """
5
- Holds scoped instances for the current context.
5
+ Manages scoped instances using Python's context variables, allowing for context-local storage of active scopes.
6
6
  """
7
+
7
8
  _active_scope = contextvars.ContextVar(
8
9
  "orionis_scope",
9
10
  default=None
@@ -12,32 +13,32 @@ class ScopedContext:
12
13
  @classmethod
13
14
  def getCurrentScope(cls):
14
15
  """
15
- Get the currently active scope.
16
+ Retrieve the currently active scope for the current context.
16
17
 
17
18
  Returns
18
19
  -------
19
20
  object or None
20
- The current active scope or None if no scope is active.
21
+ The currently active scope object, or None if no scope is set.
21
22
  """
22
23
  return cls._active_scope.get()
23
24
 
24
25
  @classmethod
25
26
  def setCurrentScope(cls, scope):
26
27
  """
27
- Set the current active scope.
28
+ Set the active scope for the current context.
28
29
 
29
30
  Parameters
30
31
  ----------
31
32
  scope : object
32
- The scope object to set as active.
33
+ The scope object to be set as the active scope for the current context.
33
34
  """
34
35
  cls._active_scope.set(scope)
35
36
 
36
37
  @classmethod
37
38
  def clear(cls):
38
39
  """
39
- Clear the current active scope.
40
+ Clear the active scope for the current context.
40
41
 
41
- Sets the active scope to None.
42
+ Resets the active scope to None.
42
43
  """
43
44
  cls._active_scope.set(None)
@@ -7,24 +7,28 @@ class IServiceProvider(ABC):
7
7
  """
8
8
  Register services into the application container.
9
9
 
10
- This method must be implemented by all concrete service providers.
11
- It should bind services, configurations, or other components
12
- to the application container.
10
+ Notes
11
+ -----
12
+ This asynchronous method must be implemented by subclasses.
13
+ It is responsible for binding services, configurations, or other
14
+ components to the application container.
13
15
 
14
16
  Raises
15
17
  ------
16
18
  NotImplementedError
17
- If the method is not overridden in a subclass.
19
+ If the method is not implemented by a subclass.
18
20
  """
19
21
  pass
20
22
 
21
23
  @abstractmethod
22
24
  async def boot(self) -> None:
23
25
  """
24
- Perform any post-registration bootstrapping or initialization.
26
+ Perform post-registration bootstrapping or initialization.
25
27
 
26
- This method is called after all services have been registered.
27
- Override this method to initialize services, set up event listeners,
28
- or perform other boot-time operations.
28
+ Notes
29
+ -----
30
+ This asynchronous method is called after all services have been registered.
31
+ Subclasses should override this method to initialize services, set up
32
+ event listeners, or perform other operations required at boot time.
29
33
  """
30
34
  pass
@@ -3,26 +3,20 @@ from orionis.foundation.contracts.application import IApplication
3
3
 
4
4
  class ServiceProvider(IServiceProvider):
5
5
  """
6
- Base service provider class for the Orionis framework.
6
+ Base class for service providers in the Orionis framework.
7
7
 
8
- This class serves as a base for all service providers in the application.
9
- Service providers are responsible for registering components and services
10
- into the application container, and initializing them when needed.
8
+ Service providers are responsible for registering and bootstrapping
9
+ services and components into the application container.
11
10
 
12
11
  Parameters
13
12
  ----------
14
13
  app : IApplication
15
14
  The application container instance to which services will be registered.
16
-
17
- Notes
18
- -----
19
- All concrete service providers should inherit from this class and implement
20
- the `register` method at minimum.
21
15
  """
22
16
 
23
17
  def __init__(self, app: IApplication) -> None:
24
18
  """
25
- Initialize the service provider with the application container.
19
+ Initialize the ServiceProvider with the application container.
26
20
 
27
21
  Parameters
28
22
  ----------
@@ -33,11 +27,10 @@ class ServiceProvider(IServiceProvider):
33
27
 
34
28
  async def register(self) -> None:
35
29
  """
36
- Register services into the application container.
30
+ Register services and components into the application container.
37
31
 
38
- This method must be implemented by all concrete service providers.
39
- It should bind services, configurations, or other components
40
- to the application container.
32
+ This method must be implemented by subclasses to bind services,
33
+ configurations, or other components to the application container.
41
34
 
42
35
  Raises
43
36
  ------
@@ -48,10 +41,10 @@ class ServiceProvider(IServiceProvider):
48
41
 
49
42
  async def boot(self) -> None:
50
43
  """
51
- Perform any post-registration bootstrapping or initialization.
44
+ Perform post-registration initialization or bootstrapping.
52
45
 
53
46
  This method is called after all services have been registered.
54
47
  Override this method to initialize services, set up event listeners,
55
48
  or perform other boot-time operations.
56
49
  """
57
- pass
50
+ pass
@@ -11,45 +11,52 @@ from orionis.services.introspection.dependencies.entities.known_dependencies imp
11
11
  from orionis.services.introspection.dependencies.entities.method_dependencies import MethodDependency
12
12
 
13
13
  class Resolver(IResolver):
14
- """
15
- Resolver class for handling dependency resolution in the container.
16
- """
17
14
 
18
15
  def __init__(
19
16
  self,
20
- container:IContainer
17
+ container: IContainer
21
18
  ):
22
19
  """
23
- Initialize the resolver.
24
-
25
- This method initializes the resolver with a reference to the container.
26
-
27
20
  Parameters
28
21
  ----------
29
22
  container : IContainer
30
- The container instance that this resolver will use to resolve dependencies.
23
+ The container instance used by the resolver to resolve dependencies.
24
+
25
+ Notes
26
+ -----
27
+ Initializes the Resolver with a reference to the dependency injection container.
28
+ This allows the resolver to access registered bindings and resolve dependencies
29
+ as required throughout the container's lifecycle.
31
30
  """
32
31
  self.container = container
33
32
 
34
33
  def resolve(
35
34
  self,
36
- binding:Binding,
35
+ binding: Binding,
37
36
  *args,
38
37
  **kwargs
39
38
  ):
40
39
  """
41
- Resolves an instance from a binding.
42
- This method resolves an instance based on the binding's lifetime and type.
43
- It delegates to specific resolution methods based on the lifetime (transient, singleton, or scoped).
44
- Args:
45
- binding (Binding): The binding to resolve.
46
- *args: Additional positional arguments to pass to the constructor.
47
- **kwargs: Additional keyword arguments to pass to the constructor.
48
- Returns:
49
- Any: The resolved instance.
50
- Raises:
51
- OrionisContainerException: If the binding is not an instance of Binding
52
- or if scoped lifetime resolution is attempted (not yet implemented).
40
+ Resolves an instance from a binding according to its lifetime.
41
+
42
+ Parameters
43
+ ----------
44
+ binding : Binding
45
+ The binding to resolve.
46
+ *args : tuple
47
+ Additional positional arguments to pass to the constructor.
48
+ **kwargs : dict
49
+ Additional keyword arguments to pass to the constructor.
50
+
51
+ Returns
52
+ -------
53
+ Any
54
+ The resolved instance.
55
+
56
+ Raises
57
+ ------
58
+ OrionisContainerException
59
+ If the binding is not an instance of Binding or if the lifetime is not supported.
53
60
  """
54
61
 
55
62
  # Ensure the binding is an instance of Binding