orionis 0.199.0__py3-none-any.whl → 0.200.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 (27) hide show
  1. orionis/framework.py +1 -1
  2. orionis/luminate/console/base/command.py +88 -80
  3. orionis/luminate/console/command_filter.py +0 -1
  4. orionis/luminate/console/commands/cache_clear.py +19 -11
  5. orionis/luminate/console/commands/help.py +19 -10
  6. orionis/luminate/console/commands/schedule_work.py +1 -4
  7. orionis/luminate/console/commands/version.py +1 -3
  8. orionis/luminate/console/exceptions/cli-orionis-value-error.py +41 -0
  9. orionis/luminate/console/exceptions/cli_exception.py +1 -127
  10. orionis/luminate/console/exceptions/cli_runtime_error.py +41 -0
  11. orionis/luminate/console/exceptions/cli_schedule_exception.py +41 -0
  12. orionis/luminate/console/output/console.py +160 -68
  13. orionis/luminate/console/output/executor.py +1 -1
  14. orionis/luminate/console/output/styles.py +12 -4
  15. orionis/luminate/console/parser.py +1 -1
  16. orionis/luminate/contracts/console/base/command.py +65 -75
  17. orionis/luminate/contracts/console/output/console.py +160 -60
  18. orionis/luminate/contracts/support/{exception_to_dict.py → exception_parse.py} +2 -2
  19. orionis/luminate/services/commands/scheduler_service.py +1 -1
  20. orionis/luminate/support/{exception_to_dict.py → exception_parse.py} +11 -16
  21. {orionis-0.199.0.dist-info → orionis-0.200.0.dist-info}/METADATA +1 -1
  22. {orionis-0.199.0.dist-info → orionis-0.200.0.dist-info}/RECORD +26 -24
  23. orionis/luminate/console/commands/tests.py +0 -34
  24. {orionis-0.199.0.dist-info → orionis-0.200.0.dist-info}/LICENCE +0 -0
  25. {orionis-0.199.0.dist-info → orionis-0.200.0.dist-info}/WHEEL +0 -0
  26. {orionis-0.199.0.dist-info → orionis-0.200.0.dist-info}/entry_points.txt +0 -0
  27. {orionis-0.199.0.dist-info → orionis-0.200.0.dist-info}/top_level.txt +0 -0
orionis/framework.py CHANGED
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.199.0"
8
+ VERSION = "0.200.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -1,6 +1,7 @@
1
- from orionis.luminate.contracts.console.base.command import IBaseCommand
1
+ import argparse
2
2
  from orionis.luminate.console.output.console import Console
3
3
  from orionis.luminate.console.output.progress_bar import ProgressBar
4
+ from orionis.luminate.contracts.console.base.command import IBaseCommand
4
5
 
5
6
  class BaseCommand(IBaseCommand):
6
7
  """
@@ -16,73 +17,73 @@ class BaseCommand(IBaseCommand):
16
17
  """
17
18
  args = {}
18
19
 
19
- def success(self, message: str, timestamp: bool = True):
20
+ def success(self, message: str, timestamp: bool = True) -> None:
20
21
  """
21
22
  Prints a success message with a green background.
22
23
 
23
24
  Parameters
24
25
  ----------
25
- message : str, optional
26
- The message to display (default is an empty string).
26
+ message : str
27
+ The message to display.
27
28
  timestamp : bool, optional
28
29
  Whether to include a timestamp (default is True).
29
30
  """
30
31
  Console.success(message, timestamp)
31
32
 
32
- def textSuccess(self, message: str):
33
+ def textSuccess(self, message: str) -> None:
33
34
  """
34
35
  Prints a success message in green.
35
36
 
36
37
  Parameters
37
38
  ----------
38
- message : str, optional
39
- The message to display (default is an empty string).
39
+ message : str
40
+ The message to display.
40
41
  """
41
42
  Console.textSuccess(message)
42
43
 
43
- def textSuccessBold(self, message: str):
44
+ def textSuccessBold(self, message: str) -> None:
44
45
  """
45
46
  Prints a bold success message in green.
46
47
 
47
48
  Parameters
48
49
  ----------
49
- message : str, optional
50
- The message to display (default is an empty string).
50
+ message : str
51
+ The message to display.
51
52
  """
52
53
  Console.textSuccessBold(message)
53
54
 
54
- def info(self, message: str, timestamp: bool = True):
55
+ def info(self, message: str, timestamp: bool = True) -> None:
55
56
  """
56
57
  Prints an informational message with a blue background.
57
58
 
58
59
  Parameters
59
60
  ----------
60
- message : str, optional
61
- The message to display (default is an empty string).
61
+ message : str
62
+ The message to display.
62
63
  timestamp : bool, optional
63
64
  Whether to include a timestamp (default is True).
64
65
  """
65
66
  Console.info(message, timestamp)
66
67
 
67
- def textInfo(self, message: str):
68
+ def textInfo(self, message: str) -> None:
68
69
  """
69
70
  Prints an informational message in blue.
70
71
 
71
72
  Parameters
72
73
  ----------
73
- message : str, optional
74
- The message to display (default is an empty string).
74
+ message : str
75
+ The message to display.
75
76
  """
76
77
  Console.textInfo(message)
77
78
 
78
- def textInfoBold(self, message: str):
79
+ def textInfoBold(self, message: str) -> None:
79
80
  """
80
81
  Prints a bold informational message in blue.
81
82
 
82
83
  Parameters
83
84
  ----------
84
- message : str, optional
85
- The message to display (default is an empty string).
85
+ message : str
86
+ The message to display.
86
87
  """
87
88
  Console.textInfoBold(message)
88
89
 
@@ -92,140 +93,135 @@ class BaseCommand(IBaseCommand):
92
93
 
93
94
  Parameters
94
95
  ----------
95
- message : str, optional
96
- The message to display (default is an empty string).
96
+ message : str
97
+ The message to display.
97
98
  timestamp : bool, optional
98
99
  Whether to include a timestamp (default is True).
99
100
  """
100
101
  Console.warning(message, timestamp)
101
102
 
102
- def textWarning(self, message: str):
103
+ def textWarning(self, message: str) -> None:
103
104
  """
104
105
  Prints a warning message in yellow.
105
106
 
106
107
  Parameters
107
108
  ----------
108
- message : str, optional
109
- The message to display (default is an empty string).
109
+ message : str
110
+ The message to display.
110
111
  """
111
112
  Console.textWarning(message)
112
113
 
113
- def textWarningBold(self, message: str):
114
+ def textWarningBold(self, message: str) -> None:
114
115
  """
115
116
  Prints a bold warning message in yellow.
116
117
 
117
118
  Parameters
118
119
  ----------
119
- message : str, optional
120
- The message to display (default is an empty string).
120
+ message : str
121
+ The message to display.
121
122
  """
122
123
  Console.textWarningBold(message)
123
124
 
124
- def fail(self, message: str, timestamp: bool = True):
125
+ def fail(self, message: str, timestamp: bool = True) -> None:
125
126
  """
126
127
  Prints a failure message with a red background.
127
128
 
128
129
  Parameters
129
130
  ----------
130
- message : str, optional
131
- The message to display (default is an empty string).
131
+ message : str
132
+ The message to display.
132
133
  timestamp : bool, optional
133
134
  Whether to include a timestamp (default is True).
134
135
  """
135
136
  Console.fail(message, timestamp)
136
137
 
137
- def error(self, message: str, timestamp: bool = True):
138
+ def error(self, message: str, timestamp: bool = True) -> None:
138
139
  """
139
140
  Prints an error message with a red background.
140
141
 
141
142
  Parameters
142
143
  ----------
143
- message : str, optional
144
- The message to display (default is an empty string).
144
+ message : str
145
+ The message to display.
145
146
  timestamp : bool, optional
146
147
  Whether to include a timestamp (default is True).
147
148
  """
148
149
  Console.error(message, timestamp)
149
150
 
150
- def textError(self, message: str):
151
+ def textError(self, message: str) -> None:
151
152
  """
152
153
  Prints an error message in red.
153
154
 
154
155
  Parameters
155
156
  ----------
156
- message : str, optional
157
- The message to display (default is an empty string).
157
+ message : str
158
+ The message to display.
158
159
  """
159
160
  Console.textError(message)
160
161
 
161
- def textErrorBold(self, message: str):
162
+ def textErrorBold(self, message: str) -> None:
162
163
  """
163
164
  Prints a bold error message in red.
164
165
 
165
166
  Parameters
166
167
  ----------
167
- message : str, optional
168
- The message to display (default is an empty string).
168
+ message : str
169
+ The message to display.
169
170
  """
170
171
  Console.textErrorBold(message)
171
172
 
172
- def textMuted(self, message: str):
173
+ def textMuted(self, message: str) -> None:
173
174
  """
174
175
  Prints a muted (gray) message.
175
176
 
176
177
  Parameters
177
178
  ----------
178
- message : str, optional
179
- The message to display (default is an empty string).
179
+ message : str
180
+ The message to display.
180
181
  """
181
182
  Console.textMuted(message)
182
183
 
183
- def textMutedBold(self, message: str):
184
+ def textMutedBold(self, message: str) -> None:
184
185
  """
185
186
  Prints a bold muted (gray) message.
186
187
 
187
188
  Parameters
188
189
  ----------
189
- message : str, optional
190
- The message to display (default is an empty string).
190
+ message : str
191
+ The message to display.
191
192
  """
192
193
  Console.textMutedBold(message)
193
194
 
194
- def textUnderline(self, message: str):
195
+ def textUnderline(self, message: str) -> None:
195
196
  """
196
197
  Prints an underlined message.
197
198
 
198
199
  Parameters
199
200
  ----------
200
- message : str, optional
201
- The message to display (default is an empty string).
201
+ message : str
202
+ The message to display.
202
203
  """
203
204
  Console.textUnderline(message)
204
205
 
205
- def clear(self):
206
+ def clear(self) -> None:
206
207
  """
207
208
  Clears the console screen.
208
209
  """
209
210
  Console.clear()
210
211
 
211
- def clearLine(self):
212
+ def clearLine(self) -> None:
212
213
  """
213
214
  Clears the current console line.
214
215
  """
215
216
  Console.clearLine()
216
217
 
217
- def line(self, message: str):
218
+ def line(self) -> None:
218
219
  """
219
- Prints a line of text.
220
-
221
- Parameters
222
- ----------
223
- message : str, optional
224
- The message to display (default is an empty string).
220
+ Prints a line empty.
225
221
  """
226
- Console.line(message)
222
+ Console.line()
227
223
 
228
- def newLine(self, count: int = 1):
224
+ def newLine(self, count: int = 1) -> None:
229
225
  """
230
226
  Prints multiple new lines.
231
227
 
@@ -236,18 +232,18 @@ class BaseCommand(IBaseCommand):
236
232
  """
237
233
  Console.newLine(count)
238
234
 
239
- def write(self, message: str):
235
+ def write(self, message: str) -> None:
240
236
  """
241
237
  Prints a message without moving to the next line.
242
238
 
243
239
  Parameters
244
240
  ----------
245
241
  message : str, optional
246
- The message to display (default is an empty string).
242
+ The message to display.
247
243
  """
248
244
  Console.write(message)
249
245
 
250
- def writeLine(self, message: str):
246
+ def writeLine(self, message: str) -> None:
251
247
  """
252
248
  Prints a message and moves to the next line.
253
249
 
@@ -272,7 +268,7 @@ class BaseCommand(IBaseCommand):
272
268
  str
273
269
  The user's input.
274
270
  """
275
- return Console.ask(question)
271
+ return Console.ask(question).strip()
276
272
 
277
273
  def confirm(self, question: str, default: bool = False) -> bool:
278
274
  """
@@ -290,7 +286,7 @@ class BaseCommand(IBaseCommand):
290
286
  bool
291
287
  The user's response.
292
288
  """
293
- return Console.ask(question, default)
289
+ return Console.confirm(question, default)
294
290
 
295
291
  def secret(self, question: str) -> str:
296
292
  """
@@ -397,21 +393,6 @@ class BaseCommand(IBaseCommand):
397
393
  """
398
394
  return ProgressBar(total=total, width=width)
399
395
 
400
- def setArgs(self, args):
401
- """
402
- Define the logic of setting command arguments.
403
-
404
- Parameters
405
- ----------
406
- args : argparse.Namespace
407
- Contain the arguments to be set for the command.
408
- """
409
- try:
410
- self.args = vars(args)
411
- except TypeError:
412
- self.args = {}
413
-
414
-
415
396
  def handle(self, **kwargs):
416
397
  """
417
398
  Abstract method to define the logic of the command.
@@ -425,4 +406,31 @@ class BaseCommand(IBaseCommand):
425
406
  NotImplementedError: If the method is not implemented in a subclass. This ensures that all command classes
426
407
  adhere to the expected structure.
427
408
  """
428
- raise NotImplementedError("The 'handle' method must be implemented in the child class.")
409
+ raise NotImplementedError("The 'handle' method must be implemented in the child class.")
410
+
411
+ def setArgs(self, args) -> None:
412
+ """
413
+ Define the logic of setting command arguments.
414
+
415
+ Parameters
416
+ ----------
417
+ args : argparse.Namespace or dict
418
+ Contain the arguments to be set for the command.
419
+ """
420
+ if isinstance(args, argparse.Namespace):
421
+ self.args = vars(args)
422
+ elif isinstance(args, dict):
423
+ self.args = args
424
+ else:
425
+ raise ValueError("Invalid argument type. Expected 'argparse.Namespace' or 'dict'.")
426
+
427
+ def getArgs(self) -> dict:
428
+ """
429
+ Get the command arguments.
430
+
431
+ Returns
432
+ -------
433
+ dict
434
+ The command arguments.
435
+ """
436
+ return self.args
@@ -33,5 +33,4 @@ class CommandFilter(ICommandFilter):
33
33
  'schedule:work', # Command to handle scheduled work
34
34
  'help', # Command to show help information
35
35
  'version', # Command to display version information
36
- 'tests:run' # Command to run tests
37
36
  ]
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  import shutil
3
3
  from orionis.luminate.console.base.command import BaseCommand
4
- from orionis.luminate.console.exceptions.cli_exception import CLIOrionisRuntimeError
4
+ from orionis.luminate.console.exceptions.cli_runtime_error import CLIOrionisRuntimeError
5
5
 
6
6
  class CacheClearCommand(BaseCommand):
7
7
  """
@@ -9,21 +9,29 @@ class CacheClearCommand(BaseCommand):
9
9
 
10
10
  This command recursively searches for and removes all `__pycache__` directories
11
11
  in the project folder to ensure that no stale bytecode files persist.
12
-
13
- Attributes
14
- ----------
15
- signature : str
16
- The unique identifier for the command, used to trigger its execution.
17
- description : str
18
- A brief summary describing the purpose of the command.
19
12
  """
20
13
 
21
- # The command signature used to execute this command.
22
14
  signature = 'cache:clear'
23
15
 
24
- # A brief description of the command.
25
16
  description = 'Clears the project cache by removing all __pycache__ directories.'
26
17
 
18
+ def __init__(self) -> None:
19
+ """
20
+ Initializes the command instance, setting the list of directories to exclude from the cache clearing process.
21
+ """
22
+ self.exclude_dirs = [
23
+ 'venv',
24
+ 'env',
25
+ 'virtualenv',
26
+ 'venv3',
27
+ 'env3',
28
+ 'venv2',
29
+ 'env2',
30
+ 'vendor',
31
+ 'node_modules',
32
+ 'environment'
33
+ ]
34
+
27
35
  def handle(self) -> None:
28
36
  """
29
37
  Executes the cache clearing process.
@@ -45,7 +53,7 @@ class CacheClearCommand(BaseCommand):
45
53
  for root, dirs, files in os.walk(base_path, topdown=True):
46
54
 
47
55
  # Skip common environment directories (e.g., venv, env, vendor, node_modules)
48
- for env_dir in ['venv', 'env', 'virtualenv', 'venv3', 'env3', 'venv2', 'env2', 'vendor', 'node_modules', 'environment']:
56
+ for env_dir in self.exclude_dirs:
49
57
  if env_dir in dirs:
50
58
  dirs.remove(env_dir)
51
59
 
@@ -1,24 +1,29 @@
1
+ from orionis.framework import NAME
1
2
  from orionis.luminate.console.base.command import BaseCommand
2
- from orionis.luminate.console.exceptions.cli_exception import CLIOrionisRuntimeError
3
+ from orionis.luminate.console.exceptions.cli_runtime_error import CLIOrionisRuntimeError
3
4
  from orionis.luminate.contracts.application import IApplication
4
- from orionis.framework import NAME
5
5
 
6
6
  class HelpCommand(BaseCommand):
7
7
  """
8
8
  Command class to display the list of available commands in the Orionis application.
9
-
10
9
  This command fetches all registered commands from the cache and presents them in a table format.
11
10
  """
12
- def __init__(self, app : IApplication):
13
- # Get the list of commands from the container
14
- self._commands : dict = app._commands if hasattr(app, '_commands') else {}
15
11
 
16
- # Command signature used for execution.
17
12
  signature = "help"
18
13
 
19
- # Brief description of the command.
20
14
  description = "Prints the list of available commands along with their descriptions."
21
15
 
16
+ def __init__(self, app : IApplication):
17
+ """
18
+ Initialize the HelpCommand class.
19
+
20
+ Parameters
21
+ ----------
22
+ app : IApplication
23
+ The application instance that is passed to the command class.
24
+ """
25
+ self._commands : dict = app._commands if hasattr(app, '_commands') else {}
26
+
22
27
  def handle(self) -> None:
23
28
  """
24
29
  Execute the help command.
@@ -41,14 +46,18 @@ class HelpCommand(BaseCommand):
41
46
  # Initialize an empty list to store the rows.
42
47
  rows = []
43
48
  for signature, command_data in self._commands.items():
44
- rows.append([signature, command_data['description']])
49
+ rows.append([
50
+ signature,
51
+ command_data['description'],
52
+ 'Core Command' if 'orionis.luminate.console.commands' in command_data['concrete'].__module__ else 'User Command'
53
+ ])
45
54
 
46
55
  # Sort commands alphabetically
47
56
  rows_sorted = sorted(rows, key=lambda x: x[0])
48
57
 
49
58
  # Display the commands in a table format
50
59
  self.table(
51
- ["Signature", "Description"],
60
+ ["Signature", "Description", "Type"],
52
61
  rows_sorted
53
62
  )
54
63
 
@@ -1,10 +1,9 @@
1
1
  import importlib
2
2
  from orionis.luminate.console.base.command import BaseCommand
3
- from orionis.luminate.console.exceptions.cli_exception import CLIOrionisRuntimeError
3
+ from orionis.luminate.console.exceptions.cli_runtime_error import CLIOrionisRuntimeError
4
4
  from orionis.luminate.contracts.console.task_manager import ITaskManager
5
5
  from orionis.luminate.facades.commands.scheduler_facade import Schedule
6
6
 
7
-
8
7
  class ScheduleWorkCommand(BaseCommand):
9
8
  """
10
9
  Command class to handle scheduled tasks within the Orionis application.
@@ -13,10 +12,8 @@ class ScheduleWorkCommand(BaseCommand):
13
12
  and starts the execution of scheduled tasks.
14
13
  """
15
14
 
16
- # The command signature used to execute this command.
17
15
  signature = "schedule:work"
18
16
 
19
- # A brief description of the command.
20
17
  description = "Starts the scheduled tasks."
21
18
 
22
19
  def __init__(self, schedule : Schedule) -> None:
@@ -1,6 +1,6 @@
1
1
  from orionis.framework import VERSION
2
2
  from orionis.luminate.console.base.command import BaseCommand
3
- from orionis.luminate.console.exceptions.cli_exception import CLIOrionisRuntimeError
3
+ from orionis.luminate.console.exceptions.cli_runtime_error import CLIOrionisRuntimeError
4
4
 
5
5
  class VersionCommand(BaseCommand):
6
6
  """
@@ -9,10 +9,8 @@ class VersionCommand(BaseCommand):
9
9
  This command prints the version number of the framework in use.
10
10
  """
11
11
 
12
- # Command signature used for execution.
13
12
  signature = "version"
14
13
 
15
- # Brief description of the command.
16
14
  description = "Prints the version of the framework in use."
17
15
 
18
16
  def handle(self) -> None:
@@ -0,0 +1,41 @@
1
+ class CLIOrionisValueError(ValueError):
2
+ """
3
+ Custom exception raised when there is a value error in Orionis data processing.
4
+
5
+ Parameters
6
+ ----------
7
+ message : str
8
+ The response message associated with the exception.
9
+
10
+ Attributes
11
+ ----------
12
+ message : str
13
+ Stores the response message passed during initialization.
14
+
15
+ Methods
16
+ -------
17
+ __str__()
18
+ Returns a string representation of the exception, including the response message.
19
+ """
20
+
21
+ def __init__(self, message: str):
22
+ """
23
+ Initializes the CLIOrionisValueError with the given response message.
24
+
25
+ Parameters
26
+ ----------
27
+ message : str
28
+ The response message associated with the exception.
29
+ """
30
+ super().__init__(message)
31
+
32
+ def __str__(self):
33
+ """
34
+ Returns a string representation of the exception, including the response message.
35
+
36
+ Returns
37
+ -------
38
+ str
39
+ A string containing the exception name and the response message.
40
+ """
41
+ return f"CLIOrionisValueError: {self.args[0]}"