orionis 0.428.0__py3-none-any.whl → 0.429.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.
- orionis/metadata/framework.py +1 -1
- {orionis-0.428.0.dist-info → orionis-0.429.0.dist-info}/METADATA +1 -1
- {orionis-0.428.0.dist-info → orionis-0.429.0.dist-info}/RECORD +7 -22
- orionis/_console/__init__.py +0 -0
- orionis/_console/command_filter.py +0 -36
- orionis/_console/commands/__init__.py +0 -0
- orionis/_console/commands/cache_clear.py +0 -76
- orionis/_console/commands/help.py +0 -70
- orionis/_console/commands/schedule_work.py +0 -55
- orionis/_console/commands/version.py +0 -31
- orionis/_console/dumper/__init__.py +0 -0
- orionis/_console/dumper/dump_die.py +0 -418
- orionis/_console/kernel.py +0 -31
- orionis/_console/output/__init__.py +0 -0
- orionis/_console/output/console.py +0 -587
- orionis/_console/output/executor.py +0 -90
- orionis/_console/output/progress_bar.py +0 -100
- orionis/_console/parser.py +0 -159
- {orionis-0.428.0.dist-info → orionis-0.429.0.dist-info}/WHEEL +0 -0
- {orionis-0.428.0.dist-info → orionis-0.429.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.428.0.dist-info → orionis-0.429.0.dist-info}/top_level.txt +0 -0
- {orionis-0.428.0.dist-info → orionis-0.429.0.dist-info}/zip-safe +0 -0
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
from orionis.console.dynamic.contracts.progress_bar import IProgressBar
|
|
3
|
-
|
|
4
|
-
class ProgressBar(IProgressBar):
|
|
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.
|
|
10
|
-
|
|
11
|
-
Parameters
|
|
12
|
-
----------
|
|
13
|
-
total : int, optional
|
|
14
|
-
The total amount of progress (default is 100).
|
|
15
|
-
width : int, optional
|
|
16
|
-
The width of the progress bar in characters (default is 50).
|
|
17
|
-
|
|
18
|
-
Attributes
|
|
19
|
-
----------
|
|
20
|
-
total : int
|
|
21
|
-
The maximum progress value.
|
|
22
|
-
bar_width : int
|
|
23
|
-
The width of the progress bar in characters.
|
|
24
|
-
progress : int
|
|
25
|
-
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
|
-
"""
|
|
36
|
-
|
|
37
|
-
def __init__(self, total=100, width=50):
|
|
38
|
-
"""
|
|
39
|
-
Constructs all the necessary attributes for the progress bar object.
|
|
40
|
-
|
|
41
|
-
Parameters
|
|
42
|
-
----------
|
|
43
|
-
total : int, optional
|
|
44
|
-
The total amount of progress (default is 100).
|
|
45
|
-
width : int, optional
|
|
46
|
-
The width of the progress bar in characters (default is 50).
|
|
47
|
-
"""
|
|
48
|
-
self.total = total
|
|
49
|
-
self.bar_width = width
|
|
50
|
-
self.progress = 0
|
|
51
|
-
|
|
52
|
-
def _update_bar(self):
|
|
53
|
-
"""
|
|
54
|
-
Updates the visual representation of the progress bar.
|
|
55
|
-
|
|
56
|
-
This method calculates the percentage of progress and updates the
|
|
57
|
-
console output accordingly.
|
|
58
|
-
"""
|
|
59
|
-
percent = self.progress / self.total
|
|
60
|
-
filled_length = int(self.bar_width * percent)
|
|
61
|
-
bar = f"[{'█' * filled_length}{'░' * (self.bar_width - filled_length)}] {int(percent * 100)}%"
|
|
62
|
-
|
|
63
|
-
# Move the cursor to the start of the line and overwrite it
|
|
64
|
-
sys.stdout.write("\r" + bar)
|
|
65
|
-
sys.stdout.flush()
|
|
66
|
-
|
|
67
|
-
def start(self):
|
|
68
|
-
"""
|
|
69
|
-
Initializes the progress bar to the starting state.
|
|
70
|
-
|
|
71
|
-
This method resets the progress to zero and displays the initial bar.
|
|
72
|
-
"""
|
|
73
|
-
self.progress = 0
|
|
74
|
-
self._update_bar()
|
|
75
|
-
|
|
76
|
-
def advance(self, increment=1):
|
|
77
|
-
"""
|
|
78
|
-
Advances the progress bar by a specific increment.
|
|
79
|
-
|
|
80
|
-
Parameters
|
|
81
|
-
----------
|
|
82
|
-
increment : int, optional
|
|
83
|
-
The amount by which the progress should be increased (default is 1).
|
|
84
|
-
"""
|
|
85
|
-
self.progress += increment
|
|
86
|
-
if self.progress > self.total:
|
|
87
|
-
self.progress = self.total
|
|
88
|
-
self._update_bar()
|
|
89
|
-
|
|
90
|
-
def finish(self):
|
|
91
|
-
"""
|
|
92
|
-
Completes the progress bar.
|
|
93
|
-
|
|
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.
|
|
96
|
-
"""
|
|
97
|
-
self.progress = self.total
|
|
98
|
-
self._update_bar()
|
|
99
|
-
sys.stdout.write("\n")
|
|
100
|
-
sys.stdout.flush()
|
orionis/_console/parser.py
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import shlex
|
|
3
|
-
import types
|
|
4
|
-
from contextlib import redirect_stderr
|
|
5
|
-
from io import StringIO
|
|
6
|
-
from orionis._contracts.console.parser import IParser
|
|
7
|
-
|
|
8
|
-
class Parser(IParser):
|
|
9
|
-
"""
|
|
10
|
-
A command-line argument parser using argparse.
|
|
11
|
-
|
|
12
|
-
This class provides methods for dynamically registering arguments,
|
|
13
|
-
parsing positional and keyword arguments, and handling errors gracefully.
|
|
14
|
-
|
|
15
|
-
Attributes
|
|
16
|
-
----------
|
|
17
|
-
argparse : argparse.ArgumentParser
|
|
18
|
-
The argument parser instance used for defining and parsing arguments.
|
|
19
|
-
args : list
|
|
20
|
-
A list storing the command-line arguments to be parsed.
|
|
21
|
-
kwargs : dict
|
|
22
|
-
A dictionary containing keyword arguments.
|
|
23
|
-
registered_arguments : set
|
|
24
|
-
A set tracking registered argument names to prevent duplicates.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
def __init__(self, vars: dict, args: tuple, kwargs: dict):
|
|
28
|
-
"""
|
|
29
|
-
Initializes the Parser class.
|
|
30
|
-
|
|
31
|
-
Parameters
|
|
32
|
-
----------
|
|
33
|
-
vars : dict
|
|
34
|
-
A dictionary containing additional variables.
|
|
35
|
-
args : tuple
|
|
36
|
-
A tuple containing command-line arguments.
|
|
37
|
-
kwargs : dict
|
|
38
|
-
A dictionary containing keyword arguments.
|
|
39
|
-
"""
|
|
40
|
-
self.argparse = argparse.ArgumentParser(description='Orionis Commands Argument Parser')
|
|
41
|
-
self.vars = vars or {}
|
|
42
|
-
self.args = list(args)
|
|
43
|
-
self.kwargs = kwargs or {}
|
|
44
|
-
self.registered_arguments = set()
|
|
45
|
-
self.parsed_arguments = []
|
|
46
|
-
|
|
47
|
-
def setArguments(self, arguments: list):
|
|
48
|
-
"""
|
|
49
|
-
Registers command-line arguments dynamically.
|
|
50
|
-
|
|
51
|
-
Parameters
|
|
52
|
-
----------
|
|
53
|
-
arguments : list of tuple
|
|
54
|
-
A list of tuples where each tuple contains:
|
|
55
|
-
- str: The argument name (e.g., '--value')
|
|
56
|
-
- dict: A dictionary of options (e.g., {'type': int, 'required': True})
|
|
57
|
-
|
|
58
|
-
Raises
|
|
59
|
-
------
|
|
60
|
-
ValueError
|
|
61
|
-
If an argument is already registered.
|
|
62
|
-
"""
|
|
63
|
-
for arg, options in arguments:
|
|
64
|
-
if arg in self.registered_arguments:
|
|
65
|
-
raise ValueError(f"Duplicate argument detected: {arg}")
|
|
66
|
-
self.argparse.add_argument(arg, **options)
|
|
67
|
-
self.registered_arguments.add(arg)
|
|
68
|
-
|
|
69
|
-
def _validateType(self, value):
|
|
70
|
-
"""
|
|
71
|
-
Validates that a value is not an instance of a class, function, or lambda.
|
|
72
|
-
|
|
73
|
-
Parameters
|
|
74
|
-
----------
|
|
75
|
-
value : any
|
|
76
|
-
The value to be validated.
|
|
77
|
-
|
|
78
|
-
Raises
|
|
79
|
-
------
|
|
80
|
-
ValueError
|
|
81
|
-
If the value is a class instance, function, or lambda.
|
|
82
|
-
"""
|
|
83
|
-
if isinstance(value, (types.FunctionType, types.LambdaType, type)):
|
|
84
|
-
raise ValueError("Command arguments cannot be functions, lambdas, or class instances.")
|
|
85
|
-
|
|
86
|
-
def recognize(self):
|
|
87
|
-
"""
|
|
88
|
-
Processes and formats command-line arguments before parsing.
|
|
89
|
-
|
|
90
|
-
Raises
|
|
91
|
-
------
|
|
92
|
-
ValueError
|
|
93
|
-
If an argument does not follow the correct format.
|
|
94
|
-
"""
|
|
95
|
-
|
|
96
|
-
# If `args` is a single list inside a list, extract it
|
|
97
|
-
if isinstance(self.args, list) and len(self.args) == 1 and isinstance(self.args[0], list):
|
|
98
|
-
all_args:list = self.args[0]
|
|
99
|
-
first_arg:str = all_args[0]
|
|
100
|
-
|
|
101
|
-
if first_arg.endswith('.py') or first_arg in ['orionis']:
|
|
102
|
-
self.args = all_args[1:]
|
|
103
|
-
else:
|
|
104
|
-
self.args = all_args
|
|
105
|
-
|
|
106
|
-
# Merge `kwargs` with `vars`
|
|
107
|
-
if isinstance(self.vars, dict):
|
|
108
|
-
self.kwargs = {**self.vars, **self.kwargs}
|
|
109
|
-
else:
|
|
110
|
-
self.args = [self.vars, *self.args]
|
|
111
|
-
|
|
112
|
-
# Process each argument in `args`
|
|
113
|
-
formatted_args = []
|
|
114
|
-
for arg in self.args:
|
|
115
|
-
self._validateType(arg)
|
|
116
|
-
|
|
117
|
-
arg = str(arg).strip()
|
|
118
|
-
if arg.startswith('--') and '=' in arg[2:]:
|
|
119
|
-
formatted_args.append(arg)
|
|
120
|
-
else:
|
|
121
|
-
raise ValueError(f'Unrecognized argument: "{arg}". Expected format: --key="value"')
|
|
122
|
-
|
|
123
|
-
# Convert `kwargs` to `--key=value` format
|
|
124
|
-
for key, value in self.kwargs.items():
|
|
125
|
-
self._validateType(value)
|
|
126
|
-
formatted_args.append(f'--{key}={shlex.quote(str(value))}')
|
|
127
|
-
|
|
128
|
-
# Replace args with processed version
|
|
129
|
-
self.parsed_arguments = formatted_args
|
|
130
|
-
|
|
131
|
-
def get(self):
|
|
132
|
-
"""
|
|
133
|
-
Parses the collected command-line arguments.
|
|
134
|
-
|
|
135
|
-
Returns
|
|
136
|
-
-------
|
|
137
|
-
argparse.Namespace
|
|
138
|
-
The parsed arguments as an object where each argument is an attribute.
|
|
139
|
-
|
|
140
|
-
Raises
|
|
141
|
-
------
|
|
142
|
-
ValueError
|
|
143
|
-
If required arguments are missing or an error occurs during parsing,
|
|
144
|
-
it raises a customized error message including the original argparse error.
|
|
145
|
-
"""
|
|
146
|
-
stderr_capture = StringIO()
|
|
147
|
-
|
|
148
|
-
try:
|
|
149
|
-
with redirect_stderr(stderr_capture):
|
|
150
|
-
return self.argparse.parse_args(self.parsed_arguments)
|
|
151
|
-
|
|
152
|
-
except SystemExit:
|
|
153
|
-
error_message = stderr_capture.getvalue().strip()
|
|
154
|
-
array_message = error_message.split('error: ')
|
|
155
|
-
final_message = str(array_message[1]).replace('unrecognized', 'Unrecognized')
|
|
156
|
-
raise ValueError(f"Argument parsing failed | {final_message} | Required arguments: {', '.join(self.registered_arguments)}")
|
|
157
|
-
|
|
158
|
-
except Exception as e:
|
|
159
|
-
raise ValueError(f"An unexpected error occurred while parsing arguments: {str(e)}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|