orionis 0.44.0__py3-none-any.whl → 0.47.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. orionis/cli_manager.py +16 -30
  2. orionis/contracts/bootstrap/i_command_bootstrapper.py +59 -0
  3. orionis/contracts/bootstrap/i_config_bootstrapper.py +112 -0
  4. orionis/contracts/bootstrap/i_environment_bootstrapper.py +33 -0
  5. orionis/{luminate/contracts/console/base/base_command_interface.py → contracts/console/base/i_command.py} +0 -1
  6. orionis/contracts/facades/config/i_config_facade.py +37 -0
  7. orionis/contracts/facades/environment/i_environment_facade.py +40 -0
  8. orionis/{luminate/contracts/facades/paths_interface.py → contracts/facades/files/i_path_facade.py} +27 -20
  9. orionis/contracts/facades/log/i_log_facade.py +83 -0
  10. orionis/{luminate/contracts/facades/tests_interface.py → contracts/facades/tests/i_tests_facade.py} +3 -6
  11. orionis/{luminate/contracts/console/scripts/management_interface.py → contracts/installer/i_installer_manager.py} +19 -16
  12. orionis/contracts/installer/i_installer_output.py +101 -0
  13. orionis/contracts/installer/i_installer_setup.py +59 -0
  14. orionis/contracts/providers/i_service_provider.py +27 -0
  15. orionis/contracts/services/config/i_config_service.py +37 -0
  16. orionis/contracts/services/files/i_path_service.py +31 -0
  17. orionis/contracts/services/log/i_log_service.py +89 -0
  18. orionis/{luminate/facades/environment.py → contracts/support/i_environment.py} +25 -32
  19. orionis/{luminate/contracts/tools/exception_to_dict_interface.py → contracts/support/i_exception_to_dict.py} +0 -9
  20. orionis/{luminate/contracts/tools/reflection_interface.py → contracts/support/i_reflection.py} +17 -8
  21. orionis/{luminate/contracts/tools/std_interface.py → contracts/support/i_std.py} +3 -16
  22. orionis/framework.py +1 -1
  23. orionis/{luminate/console/scripts/management.py → installer/installer_manager.py} +22 -16
  24. orionis/{luminate/installer/output.py → installer/installer_output.py} +16 -10
  25. orionis/{luminate/installer/setup.py → installer/installer_setup.py} +13 -25
  26. orionis/luminate/app.py +15 -11
  27. orionis/luminate/bootstrap/command_bootstrapper.py +150 -0
  28. orionis/luminate/bootstrap/config_bootstrapper.py +168 -0
  29. orionis/luminate/bootstrap/environment_bootstrapper.py +67 -0
  30. orionis/luminate/config/helpers.py +20 -0
  31. orionis/luminate/console/base/command.py +1 -3
  32. orionis/luminate/console/command_filter.py +2 -2
  33. orionis/luminate/console/commands/cache_clear.py +17 -5
  34. orionis/luminate/console/commands/help.py +19 -13
  35. orionis/luminate/console/commands/schedule_work.py +6 -3
  36. orionis/luminate/console/commands/tests.py +1 -6
  37. orionis/luminate/console/commands/version.py +0 -5
  38. orionis/luminate/console/exceptions/cli_exception.py +1 -4
  39. orionis/luminate/console/kernel.py +2 -2
  40. orionis/luminate/console/output/console.py +2 -2
  41. orionis/luminate/console/output/executor.py +1 -1
  42. orionis/luminate/console/output/progress_bar.py +1 -1
  43. orionis/luminate/console/parser.py +2 -2
  44. orionis/luminate/console/runner.py +127 -126
  45. orionis/luminate/console/tasks/scheduler.py +8 -7
  46. orionis/luminate/container/container.py +1 -1
  47. orionis/luminate/container/types.py +38 -12
  48. orionis/luminate/facades/config/config_facade.py +43 -0
  49. orionis/luminate/facades/environment/environment_facade.py +68 -0
  50. orionis/luminate/facades/{paths.py → files/path_facade.py} +50 -6
  51. orionis/luminate/facades/log/__init__.py +0 -0
  52. orionis/luminate/facades/log/log_facade.py +95 -0
  53. orionis/luminate/facades/tests/__init__.py +0 -0
  54. orionis/luminate/facades/{tests.py → tests/tests_facade.py} +1 -1
  55. orionis/luminate/patterns/__init__.py +0 -0
  56. orionis/luminate/pipelines/cli_pipeline.py +122 -116
  57. orionis/luminate/providers/__init__.py +0 -0
  58. orionis/luminate/providers/config/__init__.py +0 -0
  59. orionis/luminate/providers/config/config_service_provider.py +26 -0
  60. orionis/luminate/providers/files/__init__.py +0 -0
  61. orionis/luminate/providers/files/path_service_provider.py +26 -0
  62. orionis/luminate/providers/log/__init__.py +0 -0
  63. orionis/luminate/providers/log/log_service_provider.py +26 -0
  64. orionis/luminate/services/__init__.py +0 -0
  65. orionis/luminate/services/config/__init__.py +0 -0
  66. orionis/luminate/services/config/config_service.py +72 -0
  67. orionis/luminate/services/files/__init__.py +0 -0
  68. orionis/luminate/services/files/path_service.py +71 -0
  69. orionis/luminate/services/log/__init__.py +0 -0
  70. orionis/luminate/services/log/log_service.py +159 -0
  71. orionis/luminate/{config → support}/environment.py +21 -32
  72. orionis/luminate/{tools → support}/exception_to_dict.py +1 -1
  73. orionis/luminate/{tools → support}/reflection.py +1 -1
  74. orionis/luminate/{tools → support}/std.py +1 -1
  75. orionis/luminate/test/unit_test.py +1 -2
  76. {orionis-0.44.0.dist-info → orionis-0.47.0.dist-info}/METADATA +1 -1
  77. orionis-0.47.0.dist-info/RECORD +157 -0
  78. tests/tools/test_reflection.py +1 -1
  79. orionis/luminate/bootstrap/commands/bootstrapper.py +0 -101
  80. orionis/luminate/bootstrap/commands/register.py +0 -92
  81. orionis/luminate/bootstrap/config/bootstrapper.py +0 -79
  82. orionis/luminate/bootstrap/config/parser.py +0 -53
  83. orionis/luminate/bootstrap/config/register.py +0 -76
  84. orionis/luminate/cache/app/config.py +0 -91
  85. orionis/luminate/cache/console/commands.py +0 -97
  86. orionis/luminate/console/cache.py +0 -87
  87. orionis/luminate/console/command.py +0 -40
  88. orionis/luminate/contracts/bootstrap/commands/bootstrapper_interface.py +0 -44
  89. orionis/luminate/contracts/bootstrap/commands/register_interface.py +0 -33
  90. orionis/luminate/contracts/bootstrap/config/bootstrapper_interface.py +0 -40
  91. orionis/luminate/contracts/bootstrap/config/parser_interface.py +0 -46
  92. orionis/luminate/contracts/bootstrap/config/register_interface.py +0 -47
  93. orionis/luminate/contracts/cache/app/config_interface.py +0 -76
  94. orionis/luminate/contracts/cache/console/commands_interface.py +0 -78
  95. orionis/luminate/contracts/config/environment_interface.py +0 -64
  96. orionis/luminate/contracts/console/command_interface.py +0 -36
  97. orionis/luminate/contracts/console/runner_interface.py +0 -50
  98. orionis/luminate/contracts/facades/env_interface.py +0 -64
  99. orionis/luminate/contracts/facades/log_interface.py +0 -48
  100. orionis/luminate/contracts/files/paths_interface.py +0 -29
  101. orionis/luminate/contracts/installer/output_interface.py +0 -125
  102. orionis/luminate/contracts/installer/setup_interface.py +0 -29
  103. orionis/luminate/contracts/installer/upgrade_interface.py +0 -24
  104. orionis/luminate/contracts/log/logger_interface.py +0 -33
  105. orionis/luminate/contracts/pipelines/cli_pipeline_interface.py +0 -84
  106. orionis/luminate/contracts/publisher/pypi_publisher_interface.py +0 -36
  107. orionis/luminate/contracts/test/unit_test_interface.py +0 -51
  108. orionis/luminate/facades/config.py +0 -10
  109. orionis/luminate/facades/log.py +0 -56
  110. orionis/luminate/files/paths.py +0 -56
  111. orionis/luminate/installer/upgrade.py +0 -42
  112. orionis/luminate/log/logger.py +0 -116
  113. orionis/luminate/publisher/pypi.py +0 -215
  114. orionis-0.44.0.dist-info/RECORD +0 -156
  115. /orionis/{luminate/bootstrap/config → contracts}/__init__.py +0 -0
  116. /orionis/{luminate/cache → contracts/config}/__init__.py +0 -0
  117. /orionis/{luminate/contracts/config/config_interface.py → contracts/config/i_config.py} +0 -0
  118. /orionis/{luminate/cache/app → contracts/console}/__init__.py +0 -0
  119. /orionis/{luminate/cache/console → contracts/console/base}/__init__.py +0 -0
  120. /orionis/{luminate/contracts/console/command_filter_interface.py → contracts/console/i_command_filter.py} +0 -0
  121. /orionis/{luminate/contracts/console/kernel_interface.py → contracts/console/i_kernel.py} +0 -0
  122. /orionis/{luminate/contracts/console/parser_interface.py → contracts/console/i_parser.py} +0 -0
  123. /orionis/{luminate/contracts/console/task_manager_interface.py → contracts/console/i_task_manager.py} +0 -0
  124. /orionis/{luminate/config/dataclass → contracts/console/output}/__init__.py +0 -0
  125. /orionis/{luminate/contracts/console/output/console_interface.py → contracts/console/output/i_console.py} +0 -0
  126. /orionis/{luminate/contracts/console/output/executor_interface.py → contracts/console/output/i_executor.py} +0 -0
  127. /orionis/{luminate/contracts/console/output/progress_bar_interface.py → contracts/console/output/i_progress_bar.py} +0 -0
  128. /orionis/{luminate/console/scripts → contracts/console/tasks}/__init__.py +0 -0
  129. /orionis/{luminate/contracts/console/tasks/schedule_interface.py → contracts/console/tasks/i_schedule.py} +0 -0
  130. /orionis/{luminate/contracts/container/container_interface.py → contracts/container/i_container.py} +0 -0
  131. /orionis/{luminate/contracts/container/types_interface.py → contracts/container/i_types.py} +0 -0
  132. /orionis/{luminate/contracts → contracts/facades}/__init__.py +0 -0
  133. /orionis/{luminate/contracts/cache → contracts/facades/config}/__init__.py +0 -0
  134. /orionis/{luminate/contracts/config → contracts/facades/environment}/__init__.py +0 -0
  135. /orionis/{luminate/contracts/console → contracts/facades/files}/__init__.py +0 -0
  136. /orionis/{luminate/contracts/facades → contracts/facades/log}/__init__.py +0 -0
  137. /orionis/{luminate/contracts/files → contracts/facades/tests}/__init__.py +0 -0
  138. /orionis/{luminate/contracts → contracts}/installer/__init__.py +0 -0
  139. /orionis/{luminate/contracts/log → contracts/providers}/__init__.py +0 -0
  140. /orionis/{luminate/contracts/publisher → contracts/services}/__init__.py +0 -0
  141. /orionis/{luminate/contracts/test → contracts/services/config}/__init__.py +0 -0
  142. /orionis/{luminate/contracts/tools → contracts/services/files}/__init__.py +0 -0
  143. /orionis/{luminate/files → contracts/services/log}/__init__.py +0 -0
  144. /orionis/{luminate/installer → installer}/__init__.py +0 -0
  145. /orionis/luminate/bootstrap/{cli_exception.py → exception_bootstrapper.py} +0 -0
  146. /orionis/luminate/config/{dataclass/app.py → app.py} +0 -0
  147. /orionis/luminate/config/{dataclass/auth.py → auth.py} +0 -0
  148. /orionis/luminate/config/{dataclass/cache.py → cache.py} +0 -0
  149. /orionis/luminate/config/{dataclass/cors.py → cors.py} +0 -0
  150. /orionis/luminate/config/{dataclass/database.py → database.py} +0 -0
  151. /orionis/luminate/config/{dataclass/filesystems.py → filesystems.py} +0 -0
  152. /orionis/luminate/config/{dataclass/logging.py → logging.py} +0 -0
  153. /orionis/luminate/config/{dataclass/mail.py → mail.py} +0 -0
  154. /orionis/luminate/config/{dataclass/queue.py → queue.py} +0 -0
  155. /orionis/luminate/config/{dataclass/session.py → session.py} +0 -0
  156. /orionis/luminate/{log → facades/config}/__init__.py +0 -0
  157. /orionis/luminate/{publisher → facades/environment}/__init__.py +0 -0
  158. /orionis/luminate/{tools → facades/files}/__init__.py +0 -0
  159. /orionis/luminate/{tools → support}/dot_dict.py +0 -0
  160. /orionis/{luminate/installer → static/ascii}/icon.ascii +0 -0
  161. /orionis/{luminate/installer → static/ascii}/info.ascii +0 -0
  162. /orionis/{luminate/static → static}/bg/galaxy.jpg +0 -0
  163. /orionis/{luminate/static → static}/favicon/OrionisFrameworkFavicon.png +0 -0
  164. /orionis/{luminate/static → static}/logos/OrionisFramework.jpg +0 -0
  165. /orionis/{luminate/static → static}/logos/OrionisFramework.png +0 -0
  166. /orionis/{luminate/static → static}/logos/OrionisFramework.psd +0 -0
  167. /orionis/{luminate/static → static}/logos/OrionisFramework2.png +0 -0
  168. /orionis/{luminate/static → static}/logos/OrionisFramework3.png +0 -0
  169. {orionis-0.44.0.dist-info → orionis-0.47.0.dist-info}/LICENCE +0 -0
  170. {orionis-0.44.0.dist-info → orionis-0.47.0.dist-info}/WHEEL +0 -0
  171. {orionis-0.44.0.dist-info → orionis-0.47.0.dist-info}/entry_points.txt +0 -0
  172. {orionis-0.44.0.dist-info → orionis-0.47.0.dist-info}/top_level.txt +0 -0
@@ -38,13 +38,25 @@ class CacheClearCommand(BaseCommand):
38
38
  # Get the base project path
39
39
  base_path = os.getcwd()
40
40
 
41
+ # Normalize the base path to ensure consistent formatting
42
+ base_path = os.path.normpath(base_path)
43
+
41
44
  # Recursively traverse directories starting from the base path
42
- for root, dirs, files in os.walk(base_path):
43
- for dir in dirs:
44
- if dir == '__pycache__':
45
- # Form the path to the __pycache__ directory and remove it
46
- pycache_path = os.path.join(root, dir)
45
+ for root, dirs, files in os.walk(base_path, topdown=True):
46
+
47
+ # Skip the 'venv' directory and its subdirectories
48
+ if 'venv' in dirs:
49
+ dirs.remove('venv')
50
+
51
+ # Check for __pycache__ directories
52
+ if '__pycache__' in dirs:
53
+ pycache_path = os.path.join(root, '__pycache__')
54
+
55
+ # Attempt to remove the __pycache__ directory
56
+ try:
47
57
  shutil.rmtree(pycache_path)
58
+ except OSError as e:
59
+ self.fail(f"Error removing {pycache_path}: {e}")
48
60
 
49
61
  # Log a success message once all caches are cleared
50
62
  self.success(message='The application cache has been successfully cleared.')
@@ -1,3 +1,4 @@
1
+ from orionis.luminate.app_context import AppContext
1
2
  from orionis.luminate.console.base.command import BaseCommand
2
3
  from orionis.luminate.cache.console.commands import CacheCommands
3
4
  from orionis.luminate.console.exceptions.cli_exception import CLIOrionisRuntimeError
@@ -34,23 +35,28 @@ class HelpCommand(BaseCommand):
34
35
  self.newLine()
35
36
  self.textSuccessBold(" (CLI Interpreter) Available Commands: ")
36
37
 
37
- # Retrieve command cache
38
- cache = CacheCommands()
38
+ # Fetch the commands from the container IoC
39
+ with AppContext() as app:
39
40
 
40
- # Fetch and store commands in a structured format
41
- rows = [[command, cache.get(command)['description']] for command in cache.commands]
41
+ # Get the list of commands from the container
42
+ commands : dict = app.container._commands
42
43
 
43
- # Sort commands alphabetically
44
- rows_sorted = sorted(rows, key=lambda x: x[0])
44
+ # Initialize an empty list to store the rows.
45
+ rows = []
46
+ for signature, command_data in commands.items():
47
+ rows.append([signature, command_data['description']])
45
48
 
46
- # Display the commands in a table format
47
- self.table(
48
- ["Signature", "Description"],
49
- rows_sorted
50
- )
49
+ # Sort commands alphabetically
50
+ rows_sorted = sorted(rows, key=lambda x: x[0])
51
51
 
52
- # Add a new line after the table
53
- self.newLine()
52
+ # Display the commands in a table format
53
+ self.table(
54
+ ["Signature", "Description"],
55
+ rows_sorted
56
+ )
57
+
58
+ # Add a new line after the table
59
+ self.newLine()
54
60
 
55
61
  except Exception as e:
56
62
 
@@ -1,7 +1,9 @@
1
+ import importlib
2
+ from orionis.luminate.app_context import AppContext
1
3
  from orionis.luminate.console.base.command import BaseCommand
2
4
  from orionis.luminate.console.exceptions.cli_exception import CLIOrionisRuntimeError
3
5
  from orionis.luminate.console.tasks.scheduler import Schedule
4
- from orionis.luminate.contracts.console.task_manager_interface import ITaskManager
6
+ from orionis.contracts.console.i_task_manager import ITaskManager
5
7
 
6
8
  class ScheduleWorkCommand(BaseCommand):
7
9
  """
@@ -36,7 +38,8 @@ class ScheduleWorkCommand(BaseCommand):
36
38
  schedule = Schedule()
37
39
 
38
40
  # Create an instance of the TaskManager to manage the scheduling.
39
- from app.console.tasks_manager import TaskManager # type: ignore
41
+ tasks_manager = importlib.import_module("app.console.tasks_manager")
42
+ TaskManager = getattr(tasks_manager, "TaskManager")
40
43
  kernel: ITaskManager = TaskManager()
41
44
  kernel.schedule(schedule)
42
45
 
@@ -46,4 +49,4 @@ class ScheduleWorkCommand(BaseCommand):
46
49
  except Exception as e:
47
50
 
48
51
  # Handle any unexpected error and display the error message
49
- raise CLIOrionisRuntimeError(f"An unexpected error occurred: {e}") from e
52
+ raise CLIOrionisRuntimeError(f"An unexpected error occurred: {e}") from e
@@ -1,6 +1,6 @@
1
1
  from orionis.luminate.console.exceptions.cli_exception import CLIOrionisRuntimeError
2
- from orionis.luminate.facades.tests import UnitTests
3
2
  from orionis.luminate.console.base.command import BaseCommand
3
+ from orionis.luminate.facades.tests.tests_facade import UnitTests
4
4
 
5
5
  class TestsCommand(BaseCommand):
6
6
  """
@@ -29,11 +29,6 @@ class TestsCommand(BaseCommand):
29
29
  with the original exception message.
30
30
  """
31
31
  try:
32
-
33
- # Initialize the test suite using the custom testing framework.
34
32
  return UnitTests.execute()
35
-
36
33
  except Exception as e:
37
-
38
- # Handle any unexpected error and display the error message
39
34
  raise CLIOrionisRuntimeError(f"An unexpected error occurred: {e}") from e
@@ -28,11 +28,6 @@ class VersionCommand(BaseCommand):
28
28
  with the original exception message.
29
29
  """
30
30
  try:
31
-
32
- # Print the version number
33
31
  self.textSuccessBold(f"Orionis Framework v{VERSION}")
34
-
35
32
  except Exception as e:
36
-
37
- # Handle any unexpected error and display the error message
38
33
  raise CLIOrionisRuntimeError(f"An unexpected error occurred: {e}") from e
@@ -40,7 +40,6 @@ class CLIOrionisException(Exception):
40
40
  """
41
41
  return f"[CLIOrionisException]: {self.args[0]}"
42
42
 
43
-
44
43
  class CLIOrionisValueError(ValueError):
45
44
  """
46
45
  Custom exception raised when there is a value error in Orionis data processing.
@@ -83,7 +82,6 @@ class CLIOrionisValueError(ValueError):
83
82
  """
84
83
  return f"[CLIOrionisValueError]: {self.args[0]}"
85
84
 
86
-
87
85
  class CLIOrionisScheduleException(Exception):
88
86
  """
89
87
  Custom exception raised when there is an issue with the Orionis schedule.
@@ -126,7 +124,6 @@ class CLIOrionisScheduleException(Exception):
126
124
  """
127
125
  return f"[CLIOrionisScheduleException]: {self.args[0]}"
128
126
 
129
-
130
127
  class CLIOrionisRuntimeError(RuntimeError):
131
128
  """
132
129
  Custom exception raised when there is a runtime issue with Orionis processing.
@@ -167,4 +164,4 @@ class CLIOrionisRuntimeError(RuntimeError):
167
164
  str
168
165
  A string containing the exception name and the response message.
169
166
  """
170
- return f"[CLIOrionisRuntimeError]: {self.args[0]}"
167
+ return f"[CLIOrionisRuntimeError]: {self.args[0]}"
@@ -1,6 +1,6 @@
1
1
  from typing import Any
2
+ from orionis.contracts.console.i_kernel import ICLIKernel
2
3
  from orionis.luminate.console.runner import CLIRunner
3
- from orionis.luminate.contracts.console.kernel_interface import ICLIKernel
4
4
 
5
5
  class CLIKernel(ICLIKernel):
6
6
  """
@@ -29,4 +29,4 @@ class CLIKernel(ICLIKernel):
29
29
  Any
30
30
  The result of the executed command.
31
31
  """
32
- return CLIRunner.handle(None, {}, *args)
32
+ pass
@@ -2,9 +2,9 @@ import os
2
2
  import sys
3
3
  import getpass
4
4
  import datetime
5
+ from orionis.contracts.console.output.i_console import IConsole
5
6
  from orionis.luminate.console.output.styles import ANSIColors
6
- from orionis.luminate.contracts.console.output.console_interface import IConsole
7
- from orionis.luminate.tools.exception_to_dict import ExceptionsToDict
7
+ from orionis.luminate.support.exception_to_dict import ExceptionsToDict
8
8
 
9
9
  class Console(IConsole):
10
10
  """
@@ -1,6 +1,6 @@
1
1
  from datetime import datetime
2
+ from orionis.contracts.console.output.i_executor import IExecutor
2
3
  from orionis.luminate.console.output.styles import ANSIColors
3
- from orionis.luminate.contracts.console.output.executor_interface import IExecutor
4
4
 
5
5
  class Executor(IExecutor):
6
6
  """
@@ -1,5 +1,5 @@
1
1
  import sys
2
- from orionis.luminate.contracts.console.output.progress_bar_interface import IProgressBar
2
+ from orionis.contracts.console.output.i_progress_bar import IProgressBar
3
3
 
4
4
  class ProgressBar(IProgressBar):
5
5
  """
@@ -1,9 +1,9 @@
1
1
  import shlex
2
2
  import types
3
3
  import argparse
4
- from io import StringIO
5
4
  from contextlib import redirect_stderr
6
- from orionis.luminate.contracts.console.parser_interface import IParser
5
+ from io import StringIO
6
+ from orionis.contracts.console.i_parser import IParser
7
7
 
8
8
  class Parser(IParser):
9
9
  """
@@ -1,126 +1,127 @@
1
- import time
2
- from orionis.luminate.facades.log import Log
3
- from orionis.luminate.console.output.console import Console
4
- from orionis.luminate.console.output.executor import Executor
5
- from orionis.luminate.pipelines.cli_pipeline import CLIPipeline
6
- from orionis.luminate.console.command_filter import CommandFilter
7
- from orionis.luminate.contracts.console.runner_interface import ICLIRunner
8
-
9
- class CLIRunner(ICLIRunner):
10
- """
11
- CLIRunner manages the execution of CLI commands in Orionis.
12
-
13
- This class:
14
- - Parses command-line arguments or function parameters.
15
- - Executes commands through the `CLIPipeline`.
16
- - Logs execution status and errors.
17
-
18
- Methods
19
- -------
20
- handle(signature: str = None, vars: dict = {}, *args, **kwargs)
21
- Processes and executes a CLI command based on provided arguments.
22
- """
23
-
24
- @staticmethod
25
- def handle(signature: str = None, vars: dict = {}, *args, **kwargs):
26
- """
27
- Processes and executes a CLI command.
28
-
29
- This method:
30
- - Determines whether the command is invoked from `sys.argv` or as a function.
31
- - Extracts the command signature and arguments.
32
- - Executes the command pipeline.
33
- - Logs execution status and handles errors.
34
-
35
- Parameters
36
- ----------
37
- signature : str, optional
38
- The command signature (default is None, meaning it is extracted from `sys.argv`).
39
- vars : dict, optional
40
- Named arguments for the command (default is an empty dictionary).
41
- *args
42
- Additional arguments for the command.
43
- **kwargs
44
- Additional keyword arguments for the command.
45
-
46
- Returns
47
- -------
48
- Any
49
- The output of the executed command.
50
-
51
- Raises
52
- ------
53
- ValueError
54
- If no command signature is provided.
55
- Exception
56
- If an unexpected error occurs during execution.
57
- """
58
-
59
- try:
60
-
61
- # Exclude commands from Printing
62
- exclude_running = CommandFilter.isExcluded(signature)
63
-
64
- # Determine if command is being executed from sys.argv
65
- sys_argv = signature is None
66
-
67
- # Start execution timer
68
- start_time = time.perf_counter()
69
-
70
- # Handle command signature extraction from sys.argv
71
- if sys_argv:
72
-
73
- # Extract command signature and arguments from sys.argv
74
- if not args or len(args[0]) <= 1:
75
- raise ValueError("No command signature specified.")
76
-
77
- # Extract command signature and arguments
78
- args_list = args[0]
79
- signature, *args = args_list[1:]
80
-
81
- # Log command execution start
82
- Log.info(f"Running command: {signature}")
83
-
84
- if not exclude_running:
85
- Executor.running(program=signature)
86
-
87
- # Initialize command pipeline
88
- pipeline = CLIPipeline().getCommand(signature)
89
-
90
- # Parse arguments based on invocation type
91
- if sys_argv:
92
- pipeline.parseArguments(*args)
93
- else:
94
- pipeline.parseArguments(vars, *args, **kwargs)
95
-
96
- # Execute the command
97
- output = pipeline.execute()
98
-
99
- # Log successful execution
100
- Log.success(f"Command executed successfully: {signature}")
101
-
102
- # Calculate execution time
103
- if not exclude_running:
104
- elapsed_time = round(time.perf_counter() - start_time, 2)
105
- Executor.done(program=signature, time=f"{elapsed_time}s")
106
-
107
- # Return command output
108
- return output
109
-
110
- except ValueError as e:
111
-
112
- # Handle missing or invalid command signature
113
- Log.error(f"Command failed: {signature or 'Unknown'}, Value Error: {e}")
114
- if not exclude_running:
115
- Console.error(message=f"Value Error: {e}")
116
- elapsed_time = round(time.perf_counter() - start_time, 2)
117
- Executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
118
-
119
- except Exception as e:
120
-
121
- # Handle unexpected errors
122
- Log.error(f"Command failed: {signature or 'Unknown'}, Execution Error: {e}")
123
- if not exclude_running:
124
- Console.error(message=f"Execution Error: {e}")
125
- elapsed_time = round(time.perf_counter() - start_time, 2)
126
- Executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
1
+ # import time
2
+ # from orionis.luminate.facades.log import Log
3
+ # from orionis.luminate.console.output.console import Console
4
+ # from orionis.luminate.console.output.executor import Executor
5
+ # from orionis.luminate.pipelines.cli_pipeline import CLIPipeline
6
+ # from orionis.luminate.console.command_filter import CommandFilter
7
+ # from orionis.luminate.contracts.console.runner_interface import ICLIRunner
8
+
9
+ class CLIRunner:
10
+ pass
11
+ # """
12
+ # CLIRunner manages the execution of CLI commands in Orionis.
13
+
14
+ # This class:
15
+ # - Parses command-line arguments or function parameters.
16
+ # - Executes commands through the `CLIPipeline`.
17
+ # - Logs execution status and errors.
18
+
19
+ # Methods
20
+ # -------
21
+ # handle(signature: str = None, vars: dict = {}, *args, **kwargs)
22
+ # Processes and executes a CLI command based on provided arguments.
23
+ # """
24
+
25
+ # @staticmethod
26
+ # def handle(signature: str = None, vars: dict = {}, *args, **kwargs):
27
+ # """
28
+ # Processes and executes a CLI command.
29
+
30
+ # This method:
31
+ # - Determines whether the command is invoked from `sys.argv` or as a function.
32
+ # - Extracts the command signature and arguments.
33
+ # - Executes the command pipeline.
34
+ # - Logs execution status and handles errors.
35
+
36
+ # Parameters
37
+ # ----------
38
+ # signature : str, optional
39
+ # The command signature (default is None, meaning it is extracted from `sys.argv`).
40
+ # vars : dict, optional
41
+ # Named arguments for the command (default is an empty dictionary).
42
+ # *args
43
+ # Additional arguments for the command.
44
+ # **kwargs
45
+ # Additional keyword arguments for the command.
46
+
47
+ # Returns
48
+ # -------
49
+ # Any
50
+ # The output of the executed command.
51
+
52
+ # Raises
53
+ # ------
54
+ # ValueError
55
+ # If no command signature is provided.
56
+ # Exception
57
+ # If an unexpected error occurs during execution.
58
+ # """
59
+
60
+ # try:
61
+
62
+ # # Exclude commands from Printing
63
+ # exclude_running = CommandFilter.isExcluded(signature)
64
+
65
+ # # Determine if command is being executed from sys.argv
66
+ # sys_argv = signature is None
67
+
68
+ # # Start execution timer
69
+ # start_time = time.perf_counter()
70
+
71
+ # # Handle command signature extraction from sys.argv
72
+ # if sys_argv:
73
+
74
+ # # Extract command signature and arguments from sys.argv
75
+ # if not args or len(args[0]) <= 1:
76
+ # raise ValueError("No command signature specified.")
77
+
78
+ # # Extract command signature and arguments
79
+ # args_list = args[0]
80
+ # signature, *args = args_list[1:]
81
+
82
+ # # Log command execution start
83
+ # Log.info(f"Running command: {signature}")
84
+
85
+ # if not exclude_running:
86
+ # Executor.running(program=signature)
87
+
88
+ # # Initialize command pipeline
89
+ # pipeline = CLIPipeline().getCommand(signature)
90
+
91
+ # # Parse arguments based on invocation type
92
+ # if sys_argv:
93
+ # pipeline.parseArguments(*args)
94
+ # else:
95
+ # pipeline.parseArguments(vars, *args, **kwargs)
96
+
97
+ # # Execute the command
98
+ # output = pipeline.execute()
99
+
100
+ # # Log successful execution
101
+ # Log.success(f"Command executed successfully: {signature}")
102
+
103
+ # # Calculate execution time
104
+ # if not exclude_running:
105
+ # elapsed_time = round(time.perf_counter() - start_time, 2)
106
+ # Executor.done(program=signature, time=f"{elapsed_time}s")
107
+
108
+ # # Return command output
109
+ # return output
110
+
111
+ # except ValueError as e:
112
+
113
+ # # Handle missing or invalid command signature
114
+ # Log.error(f"Command failed: {signature or 'Unknown'}, Value Error: {e}")
115
+ # if not exclude_running:
116
+ # Console.error(message=f"Value Error: {e}")
117
+ # elapsed_time = round(time.perf_counter() - start_time, 2)
118
+ # Executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
119
+
120
+ # except Exception as e:
121
+
122
+ # # Handle unexpected errors
123
+ # Log.error(f"Command failed: {signature or 'Unknown'}, Execution Error: {e}")
124
+ # if not exclude_running:
125
+ # Console.error(message=f"Execution Error: {e}")
126
+ # elapsed_time = round(time.perf_counter() - start_time, 2)
127
+ # Executor.fail(program=signature or "Unknown", time=f"{elapsed_time}s")
@@ -1,14 +1,15 @@
1
+ import logging
1
2
  import re
2
3
  import sys
3
4
  import time
4
- import logging
5
- from typing import Any
6
5
  from datetime import datetime
6
+ from typing import Any
7
+ from apscheduler.schedulers.background import BackgroundScheduler
7
8
  from apscheduler.triggers.cron import CronTrigger
8
- from orionis.luminate.console.command import Command
9
9
  from apscheduler.triggers.interval import IntervalTrigger
10
- from apscheduler.schedulers.background import BackgroundScheduler
11
- from orionis.luminate.contracts.console.tasks.schedule_interface import ISchedule
10
+ from orionis.contracts.console.tasks.i_schedule import ISchedule
11
+ from orionis.luminate.app_context import AppContext
12
+ from orionis.luminate.console.command import Command
12
13
  from orionis.luminate.console.exceptions.cli_exception import CLIOrionisScheduleException
13
14
 
14
15
  class Schedule(ISchedule):
@@ -65,10 +66,10 @@ class Schedule(ISchedule):
65
66
  Schedule
66
67
  Returns the Schedule instance itself, allowing method chaining.
67
68
  """
68
- # Store the command logic as a lambda function
69
69
  def func():
70
70
  try:
71
- Command.call(signature, vars, *args, **kwargs)
71
+ with AppContext() as app:
72
+ app.container.makeCommand(signature, vars, *args, **kwargs)
72
73
  finally:
73
74
  if not self.scheduler.get_jobs():
74
75
  self.wait = False
@@ -2,9 +2,9 @@ import inspect
2
2
  from collections import deque
3
3
  from threading import Lock
4
4
  from typing import Callable, Any, Dict
5
+ from orionis.contracts.container.i_container import IContainer
5
6
  from orionis.luminate.container.exception import OrionisContainerException, OrionisContainerValueError, OrionisContainerTypeError
6
7
  from orionis.luminate.container.types import Types
7
- from orionis.luminate.contracts.container.container_interface import IContainer
8
8
 
9
9
  BINDING = 'binding'
10
10
  TRANSIENT = 'transient'
@@ -1,9 +1,24 @@
1
- from orionis.luminate.contracts.container.types_interface import ITypes
1
+ from orionis.contracts.container.i_types import ITypes
2
2
 
3
3
  class Types(ITypes):
4
- """A class that handles validation of primitive types to prevent registering services with primitive-type names."""
4
+ """
5
+ A class that handles validation of primitive types to prevent registering services with primitive-type names.
6
+
7
+ This class provides a method to check if a given name corresponds to a primitive type.
8
+ It is used to ensure that services or aliases are not registered with names that conflict
9
+ with Python's built-in primitive types.
10
+
11
+ Attributes
12
+ ----------
13
+ _primitive_types : set
14
+ A set containing Python's built-in primitive types and their string representations.
15
+
16
+ Methods
17
+ -------
18
+ isPrimitive(name: str) -> bool
19
+ Checks if the provided name corresponds to a primitive type.
20
+ """
5
21
 
6
- # A set of common primitive types in Python
7
22
  _primitive_types = {
8
23
  int, float, str, bool, bytes, type(None), complex,
9
24
  list, tuple, dict, set, frozenset,
@@ -11,15 +26,26 @@ class Types(ITypes):
11
26
  "list", "tuple", "dict", "set", "frozenset"
12
27
  }
13
28
 
14
- def isPrimitive(self, name: str) -> None:
15
- """Checks if the provided name corresponds to a primitive type.
29
+ def isPrimitive(self, name: str) -> bool:
30
+ """
31
+ Checks if the provided name corresponds to a primitive type.
32
+
33
+ This method is used to prevent registering services or aliases with names that
34
+ conflict with Python's built-in primitive types.
35
+
36
+ Parameters
37
+ ----------
38
+ name : str
39
+ The name of the service or alias to check.
16
40
 
17
- Args:
18
- name (str): The name of the service or alias to check.
41
+ Returns
42
+ -------
43
+ bool
44
+ True if the name corresponds to a primitive type, False otherwise.
19
45
 
20
- Raises:
21
- OrionisContainerException: If the name matches a primitive type.
46
+ Raises
47
+ ------
48
+ OrionisContainerException
49
+ If the name matches a primitive type (not implemented in this method).
22
50
  """
23
- if name in self._primitive_types:
24
- return True
25
- return False
51
+ return name in self._primitive_types
@@ -0,0 +1,43 @@
1
+ from typing import Any, Optional
2
+ from orionis.contracts.facades.config.i_config_facade import IConfig
3
+ from orionis.luminate.app_context import AppContext
4
+ from orionis.luminate.services.config.config_service import ConfigService
5
+
6
+ class Config(IConfig):
7
+
8
+ @staticmethod
9
+ def set(key: str, value: Any) -> None:
10
+ """
11
+ Dynamically sets a configuration value using dot notation.
12
+
13
+ Parameters
14
+ ----------
15
+ key : str
16
+ The configuration key (e.g., 'app.debug').
17
+ value : Any
18
+ The value to set.
19
+ """
20
+ with AppContext() as app:
21
+ config_service : ConfigService = app.container.make(ConfigService)
22
+ config_service.set(key, value)
23
+
24
+ @staticmethod
25
+ def get(key: str, default: Optional[Any] = None) -> Any:
26
+ """
27
+ Retrieves a configuration value using dot notation.
28
+
29
+ Parameters
30
+ ----------
31
+ key : str
32
+ The configuration key (e.g., 'app.debug').
33
+ default : Optional[Any]
34
+ The default value to return if the key is not found.
35
+
36
+ Returns
37
+ -------
38
+ Any
39
+ The configuration value or the default value if the key is not found.
40
+ """
41
+ with AppContext() as app:
42
+ config_service : ConfigService = app.container.make(ConfigService)
43
+ return config_service.get(key, default)