argenta 1.0.0a2__py3-none-any.whl → 1.0.0a4__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.
- argenta/app/autocompleter/entity.py +2 -2
- argenta/app/models.py +22 -35
- argenta/app/registered_routers/entity.py +4 -10
- argenta/router/command_handler/entity.py +5 -13
- argenta/router/entity.py +1 -1
- {argenta-1.0.0a2.dist-info → argenta-1.0.0a4.dist-info}/METADATA +5 -6
- {argenta-1.0.0a2.dist-info → argenta-1.0.0a4.dist-info}/RECORD +9 -10
- argenta/app/exceptions.py +0 -8
- {argenta-1.0.0a2.dist-info → argenta-1.0.0a4.dist-info}/WHEEL +0 -0
- {argenta-1.0.0a2.dist-info → argenta-1.0.0a4.dist-info}/licenses/LICENSE +0 -0
@@ -14,7 +14,7 @@ class AutoCompleter:
|
|
14
14
|
self.autocomplete_button = autocomplete_button
|
15
15
|
self.matches: list[str] = []
|
16
16
|
|
17
|
-
def
|
17
|
+
def _complete(self, text, state) -> str | None:
|
18
18
|
"""
|
19
19
|
Private. Auto-completion function
|
20
20
|
:param text: part of the command being entered
|
@@ -51,7 +51,7 @@ class AutoCompleter:
|
|
51
51
|
for line in all_commands:
|
52
52
|
readline.add_history(line)
|
53
53
|
|
54
|
-
readline.set_completer(self.
|
54
|
+
readline.set_completer(self._complete)
|
55
55
|
readline.set_completer_delims(readline.get_completer_delims().replace(' ', ''))
|
56
56
|
readline.parse_and_bind(f'{self.autocomplete_button}: complete')
|
57
57
|
|
argenta/app/models.py
CHANGED
@@ -15,7 +15,6 @@ from argenta.command.exceptions import (UnprocessedInputFlagException,
|
|
15
15
|
RepeatedInputFlagsException,
|
16
16
|
EmptyInputCommandException,
|
17
17
|
BaseInputCommandException)
|
18
|
-
from argenta.app.exceptions import NoRegisteredHandlersException
|
19
18
|
from argenta.app.registered_routers.entity import RegisteredRouters
|
20
19
|
|
21
20
|
|
@@ -62,58 +61,58 @@ class BaseApp:
|
|
62
61
|
self._exit_command_handler: Callable[[], None] = lambda: print_func(self._farewell_message)
|
63
62
|
|
64
63
|
|
65
|
-
def set_description_message_pattern(self,
|
64
|
+
def set_description_message_pattern(self, _: Callable[[str, str], str]) -> None:
|
66
65
|
"""
|
67
66
|
Public. Sets the output pattern of the available commands
|
68
|
-
:param
|
67
|
+
:param _: output pattern of the available commands
|
69
68
|
:return: None
|
70
69
|
"""
|
71
|
-
self._description_message_gen: Callable[[str, str], str] =
|
70
|
+
self._description_message_gen: Callable[[str, str], str] = _
|
72
71
|
|
73
72
|
|
74
|
-
def set_invalid_input_flags_handler(self,
|
73
|
+
def set_invalid_input_flags_handler(self, _: Callable[[str], None]) -> None:
|
75
74
|
"""
|
76
75
|
Public. Sets the handler for incorrect flags when entering a command
|
77
|
-
:param
|
76
|
+
:param _: handler for incorrect flags when entering a command
|
78
77
|
:return: None
|
79
78
|
"""
|
80
|
-
self._invalid_input_flags_handler =
|
79
|
+
self._invalid_input_flags_handler = _
|
81
80
|
|
82
81
|
|
83
|
-
def set_repeated_input_flags_handler(self,
|
82
|
+
def set_repeated_input_flags_handler(self, _: Callable[[str], None]) -> None:
|
84
83
|
"""
|
85
84
|
Public. Sets the handler for repeated flags when entering a command
|
86
|
-
:param
|
85
|
+
:param _: handler for repeated flags when entering a command
|
87
86
|
:return: None
|
88
87
|
"""
|
89
|
-
self._repeated_input_flags_handler =
|
88
|
+
self._repeated_input_flags_handler = _
|
90
89
|
|
91
90
|
|
92
|
-
def set_unknown_command_handler(self,
|
91
|
+
def set_unknown_command_handler(self, _: Callable[[str], None]) -> None:
|
93
92
|
"""
|
94
93
|
Public. Sets the handler for unknown commands when entering a command
|
95
|
-
:param
|
94
|
+
:param _: handler for unknown commands when entering a command
|
96
95
|
:return: None
|
97
96
|
"""
|
98
|
-
self._unknown_command_handler =
|
97
|
+
self._unknown_command_handler = _
|
99
98
|
|
100
99
|
|
101
|
-
def set_empty_command_handler(self,
|
100
|
+
def set_empty_command_handler(self, _: Callable[[], None]) -> None:
|
102
101
|
"""
|
103
102
|
Public. Sets the handler for empty commands when entering a command
|
104
|
-
:param
|
103
|
+
:param _: handler for empty commands when entering a command
|
105
104
|
:return: None
|
106
105
|
"""
|
107
|
-
self._empty_input_command_handler =
|
106
|
+
self._empty_input_command_handler = _
|
108
107
|
|
109
108
|
|
110
|
-
def set_exit_command_handler(self,
|
109
|
+
def set_exit_command_handler(self, _: Callable[[], None]) -> None:
|
111
110
|
"""
|
112
111
|
Public. Sets the handler for exit command when entering a command
|
113
|
-
:param
|
112
|
+
:param _: handler for exit command when entering a command
|
114
113
|
:return: None
|
115
114
|
"""
|
116
|
-
self._exit_command_handler =
|
115
|
+
self._exit_command_handler = _
|
117
116
|
|
118
117
|
|
119
118
|
def _print_command_group_description(self) -> None:
|
@@ -184,11 +183,6 @@ class BaseApp:
|
|
184
183
|
else:
|
185
184
|
if input_command_trigger in self._all_registered_triggers_in_default_case:
|
186
185
|
return False
|
187
|
-
|
188
|
-
with redirect_stdout(io.StringIO()) as f:
|
189
|
-
self._unknown_command_handler(command)
|
190
|
-
res: str = f.getvalue()
|
191
|
-
self._print_framed_text(res)
|
192
186
|
return True
|
193
187
|
|
194
188
|
|
@@ -208,16 +202,6 @@ class BaseApp:
|
|
208
202
|
self._empty_input_command_handler()
|
209
203
|
|
210
204
|
|
211
|
-
def _validate_included_routers(self) -> None:
|
212
|
-
"""
|
213
|
-
Private. Validates included routers
|
214
|
-
:return: None
|
215
|
-
"""
|
216
|
-
for router in self._registered_routers:
|
217
|
-
if not router.get_command_handlers():
|
218
|
-
raise NoRegisteredHandlersException(router.get_name())
|
219
|
-
|
220
|
-
|
221
205
|
def _setup_system_router(self) -> None:
|
222
206
|
"""
|
223
207
|
Private. Sets up system router
|
@@ -259,7 +243,6 @@ class BaseApp:
|
|
259
243
|
"""
|
260
244
|
self._setup_default_view()
|
261
245
|
self._setup_system_router()
|
262
|
-
self._validate_included_routers()
|
263
246
|
|
264
247
|
for router_entity in self._registered_routers:
|
265
248
|
self._all_registered_triggers_in_default_case.extend(router_entity.get_triggers())
|
@@ -351,6 +334,10 @@ class App(BaseApp):
|
|
351
334
|
return
|
352
335
|
|
353
336
|
if self._is_unknown_command(input_command):
|
337
|
+
with redirect_stdout(io.StringIO()) as f:
|
338
|
+
self._unknown_command_handler(input_command)
|
339
|
+
res: str = f.getvalue()
|
340
|
+
self._print_framed_text(res)
|
354
341
|
continue
|
355
342
|
|
356
343
|
with redirect_stdout(io.StringIO()) as f:
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from typing import Iterator
|
2
|
+
|
1
3
|
from argenta.router import Router
|
2
4
|
|
3
5
|
|
@@ -25,16 +27,8 @@ class RegisteredRouters:
|
|
25
27
|
"""
|
26
28
|
self._registered_routers.append(router)
|
27
29
|
|
28
|
-
def
|
29
|
-
"""
|
30
|
-
Private. Adds new registered routers
|
31
|
-
:param routers: registered routers
|
32
|
-
:return: None
|
33
|
-
"""
|
34
|
-
self._registered_routers.extend(routers)
|
35
|
-
|
36
|
-
def __iter__(self):
|
30
|
+
def __iter__(self) -> Iterator[Router]:
|
37
31
|
return iter(self._registered_routers)
|
38
32
|
|
39
|
-
def __next__(self):
|
33
|
+
def __next__(self) -> Router:
|
40
34
|
return next(iter(self._registered_routers))
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Callable
|
1
|
+
from typing import Callable, Iterator
|
2
2
|
|
3
3
|
from argenta.command import Command
|
4
4
|
from argenta.command.flag import InputFlags
|
@@ -49,14 +49,14 @@ class CommandHandlers:
|
|
49
49
|
"""
|
50
50
|
self.command_handlers = command_handlers if command_handlers else []
|
51
51
|
|
52
|
-
def
|
52
|
+
def get_handlers(self) -> list[CommandHandler]:
|
53
53
|
"""
|
54
54
|
Private. Returns the list of CommandHandlers
|
55
55
|
:return: the list of CommandHandlers as list[CommandHandler]
|
56
56
|
"""
|
57
57
|
return self.command_handlers
|
58
58
|
|
59
|
-
def
|
59
|
+
def add_handler(self, command_handler: CommandHandler) -> None:
|
60
60
|
"""
|
61
61
|
Private. Adds a CommandHandler to the list of CommandHandlers
|
62
62
|
:param command_handler: CommandHandler to be added
|
@@ -64,16 +64,8 @@ class CommandHandlers:
|
|
64
64
|
"""
|
65
65
|
self.command_handlers.append(command_handler)
|
66
66
|
|
67
|
-
def
|
68
|
-
"""
|
69
|
-
Private. Extend a many CommandHandler to the list of CommandHandlers
|
70
|
-
:param command_handlers: many CommandHandler to be added
|
71
|
-
:return: None
|
72
|
-
"""
|
73
|
-
self.command_handlers.extend(command_handlers)
|
74
|
-
|
75
|
-
def __iter__(self):
|
67
|
+
def __iter__(self) -> Iterator[CommandHandler]:
|
76
68
|
return iter(self.command_handlers)
|
77
69
|
|
78
|
-
def __next__(self):
|
70
|
+
def __next__(self) -> CommandHandler:
|
79
71
|
return next(iter(self.command_handlers))
|
argenta/router/entity.py
CHANGED
@@ -35,7 +35,7 @@ class Router:
|
|
35
35
|
|
36
36
|
def command_decorator(func):
|
37
37
|
Router._validate_func_args(command, func)
|
38
|
-
self._command_handlers.
|
38
|
+
self._command_handlers.add_handler(CommandHandler(func, command))
|
39
39
|
|
40
40
|
def wrapper(*args, **kwargs):
|
41
41
|
return func(*args, **kwargs)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: argenta
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.0a4
|
4
4
|
Summary: Python library for creating TUI
|
5
5
|
Author-email: kolo <kolo.is.main@gmail.com>
|
6
6
|
License: MIT
|
@@ -189,9 +189,9 @@ class App(BaseApp)
|
|
189
189
|
#### \_\_init\_\_
|
190
190
|
|
191
191
|
```python
|
192
|
-
def __init__(prompt: str = '
|
193
|
-
initial_message: str = '
|
194
|
-
farewell_message: str = '
|
192
|
+
def __init__(prompt: str = 'What do you want to do?',
|
193
|
+
initial_message: str = 'Argenta',
|
194
|
+
farewell_message: str = 'See you',
|
195
195
|
exit_command: Command = Command('Q', 'Exit command'),
|
196
196
|
system_router_title: str | None = 'System points:',
|
197
197
|
ignore_command_register: bool = True,
|
@@ -231,8 +231,7 @@ Configures and manages all aspects of the behavior and presentation of the user
|
|
231
231
|
#### set\_description\_message\_pattern
|
232
232
|
|
233
233
|
```python
|
234
|
-
def set_description_message_pattern(
|
235
|
-
pattern: Callable[[str, str], str]) -> None
|
234
|
+
def set_description_message_pattern(pattern: Callable[[str, str], str]) -> None
|
236
235
|
```
|
237
236
|
|
238
237
|
Public. Sets the output pattern of the available commands
|
@@ -1,14 +1,13 @@
|
|
1
1
|
argenta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
argenta/app/__init__.py,sha256=I8FTXU17ajDI-hbC6Rw0LxLmvDYipdQaos3v1pmu14E,57
|
3
3
|
argenta/app/defaults.py,sha256=GE4UzsJ7PD7654weNzTFGcBroc_0Zy5H9VL5P8ZbFek,393
|
4
|
-
argenta/app/
|
5
|
-
argenta/app/models.py,sha256=jz9CVeNLk2yKG_2bNIZPjHefcASj2xN_zzp04s0x5qY,17662
|
4
|
+
argenta/app/models.py,sha256=4hGZhJ7t2bq8QgkDmH_ePghEhybJn0DYLo4t4gyc6rg,17160
|
6
5
|
argenta/app/autocompleter/__init__.py,sha256=VT_p3QA78UnczV7pYR2NnwQ0Atd8mnDUnLazvUQNqJk,93
|
7
|
-
argenta/app/autocompleter/entity.py,sha256=
|
6
|
+
argenta/app/autocompleter/entity.py,sha256=6IurcSTLfiEYrh-yYsCYjrKsJ8_9xds3fxs5sr0FoqE,2901
|
8
7
|
argenta/app/dividing_line/__init__.py,sha256=jJZDDZix8XYCAUWW4FzGJH0JmJlchYcx0FPWifjgv1I,147
|
9
8
|
argenta/app/dividing_line/models.py,sha256=pDHZsUhgMJOGusMigS93a-4KXM-zqdQkahCdg2wuD2A,2269
|
10
9
|
argenta/app/registered_routers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
argenta/app/registered_routers/entity.py,sha256=
|
10
|
+
argenta/app/registered_routers/entity.py,sha256=hNaY3YfCp62Dk3U1XGvqTjt8mYDzgXcMsgNJMAqIU4w,1076
|
12
11
|
argenta/command/__init__.py,sha256=Plo2Da0fhq8H1eo2mg7nA1-OBLuGjK2BYpDGRvGGMIU,67
|
13
12
|
argenta/command/exceptions.py,sha256=FLX4z7-mvCTRKO7_2_FfJVUbfNLf_Z-vwyZYDy6cnnY,1030
|
14
13
|
argenta/command/models.py,sha256=-CTHYhiBYOUz-XmkNPIxC8-Ma0rb7e1uYwLodQlW4D4,6604
|
@@ -23,11 +22,11 @@ argenta/orchestrator/argparser/arguments/__init__.py,sha256=4T55Tl_4WKOYp9HtVDmz
|
|
23
22
|
argenta/orchestrator/argparser/arguments/models.py,sha256=hSUXBjTsyzNKvyPgWhiNCa4SSQdmixIQnne2A9iuPMc,1546
|
24
23
|
argenta/router/__init__.py,sha256=ldrIWTXNLXUAMAGQ8ex4e8nMso_fhi01nZi2DVzHnnk,66
|
25
24
|
argenta/router/defaults.py,sha256=RX3DMbZk7XUbj6uR4uADhZOPqEDoeCz9X-n26YTCCPM,87
|
26
|
-
argenta/router/entity.py,sha256=
|
25
|
+
argenta/router/entity.py,sha256=kW_mdL15V9jpRW72Z21sDMvsV3gVO6Bub0hKthYo8ao,7957
|
27
26
|
argenta/router/exceptions.py,sha256=q6y-4gmbgkX-0U4-qXHDP5HTtUQ_c4svaqVILn-ZzRw,852
|
28
27
|
argenta/router/command_handler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
|
-
argenta/router/command_handler/entity.py,sha256=
|
30
|
-
argenta-1.0.
|
31
|
-
argenta-1.0.
|
32
|
-
argenta-1.0.
|
33
|
-
argenta-1.0.
|
28
|
+
argenta/router/command_handler/entity.py,sha256=VjSh5tpU-nGKkf8FUn5H_35DN7ZnwVaoVXOVqkoracE,2526
|
29
|
+
argenta-1.0.0a4.dist-info/METADATA,sha256=cEC4BA9DRBaQleUKOoB0sqQshXbFvd2vpuhMeRD5cGg,25723
|
30
|
+
argenta-1.0.0a4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
31
|
+
argenta-1.0.0a4.dist-info/licenses/LICENSE,sha256=zmqoGh2n5rReBv4s8wPxF_gZEZDgauJYSPMuPczgOiU,1082
|
32
|
+
argenta-1.0.0a4.dist-info/RECORD,,
|
argenta/app/exceptions.py
DELETED
File without changes
|
File without changes
|