argenta 0.5.0a0__py3-none-any.whl → 0.5.0b2__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 +0 -1
- argenta/app/exceptions.py +0 -5
- argenta/app/models.py +10 -13
- {argenta-0.5.0a0.dist-info → argenta-0.5.0b2.dist-info}/METADATA +33 -13
- {argenta-0.5.0a0.dist-info → argenta-0.5.0b2.dist-info}/RECORD +7 -7
- {argenta-0.5.0a0.dist-info → argenta-0.5.0b2.dist-info}/WHEEL +1 -1
- {argenta-0.5.0a0.dist-info → argenta-0.5.0b2.dist-info}/LICENSE +0 -0
argenta/app/exceptions.py
CHANGED
argenta/app/models.py
CHANGED
@@ -15,8 +15,7 @@ from argenta.command.exceptions import (UnprocessedInputFlagException,
|
|
15
15
|
RepeatedInputFlagsException,
|
16
16
|
EmptyInputCommandException,
|
17
17
|
BaseInputCommandException)
|
18
|
-
from argenta.app.exceptions import (
|
19
|
-
NoRegisteredRoutersException,
|
18
|
+
from argenta.app.exceptions import (NoRegisteredRoutersException,
|
20
19
|
NoRegisteredHandlersException)
|
21
20
|
from argenta.app.registered_routers.entity import RegisteredRouters
|
22
21
|
|
@@ -32,7 +31,7 @@ class AppInit:
|
|
32
31
|
ignore_command_register: bool = True,
|
33
32
|
dividing_line: StaticDividingLine | DynamicDividingLine = StaticDividingLine(),
|
34
33
|
repeat_command_groups: bool = True,
|
35
|
-
|
34
|
+
override_system_messages: bool = False,
|
36
35
|
autocompleter: AutoCompleter = AutoCompleter(),
|
37
36
|
print_func: Callable[[str], None] = Console().print) -> None:
|
38
37
|
self._prompt = prompt
|
@@ -42,7 +41,7 @@ class AppInit:
|
|
42
41
|
self._dividing_line = dividing_line
|
43
42
|
self._ignore_command_register = ignore_command_register
|
44
43
|
self._repeat_command_groups_description = repeat_command_groups
|
45
|
-
self.
|
44
|
+
self._override_system_messages = override_system_messages
|
46
45
|
self._autocompleter = autocompleter
|
47
46
|
|
48
47
|
self._farewell_message = farewell_message
|
@@ -53,10 +52,10 @@ class AppInit:
|
|
53
52
|
self._registered_routers: RegisteredRouters = RegisteredRouters()
|
54
53
|
self._messages_on_startup = []
|
55
54
|
|
56
|
-
self._invalid_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'[red bold]Incorrect flag syntax: {raw_command}')
|
57
|
-
self._repeated_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'[red bold]Repeated input flags: {raw_command}')
|
55
|
+
self._invalid_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'[red bold]Incorrect flag syntax: {escape(raw_command)}')
|
56
|
+
self._repeated_input_flags_handler: Callable[[str], None] = lambda raw_command: print_func(f'[red bold]Repeated input flags: {escape(raw_command)}')
|
58
57
|
self._empty_input_command_handler: Callable[[], None] = lambda: print_func('[red bold]Empty input command')
|
59
|
-
self._unknown_command_handler: Callable[[InputCommand], None] = lambda command: print_func(f"[red bold]Unknown command: {command.get_trigger()}")
|
58
|
+
self._unknown_command_handler: Callable[[InputCommand], None] = lambda command: print_func(f"[red bold]Unknown command: {escape(command.get_trigger())}")
|
60
59
|
self._exit_command_handler: Callable[[], None] = lambda: print_func(self._farewell_message)
|
61
60
|
|
62
61
|
|
@@ -112,7 +111,7 @@ class AppNonStandardHandlers(AppPrinters):
|
|
112
111
|
if self._ignore_command_register:
|
113
112
|
system_router.input_command_handler(command)
|
114
113
|
return True
|
115
|
-
elif command.get_trigger() == self._exit_command:
|
114
|
+
elif command.get_trigger() == self._exit_command.get_trigger():
|
116
115
|
system_router.input_command_handler(command)
|
117
116
|
return True
|
118
117
|
return False
|
@@ -128,7 +127,7 @@ class AppNonStandardHandlers(AppPrinters):
|
|
128
127
|
elif handled_command_trigger == command.get_trigger():
|
129
128
|
return False
|
130
129
|
elif handled_command_aliases:
|
131
|
-
if command.get_trigger().lower() in [x.lower() for x in handled_command_aliases] and self._ignore_command_register:
|
130
|
+
if (command.get_trigger().lower() in [x.lower() for x in handled_command_aliases]) and self._ignore_command_register:
|
132
131
|
return False
|
133
132
|
elif command.get_trigger() in handled_command_trigger:
|
134
133
|
return False
|
@@ -179,7 +178,7 @@ class AppSetups(AppValidators, AppPrinters):
|
|
179
178
|
self._registered_routers.add_registered_router(system_router)
|
180
179
|
|
181
180
|
def _setup_default_view(self):
|
182
|
-
if not self.
|
181
|
+
if not self._override_system_messages:
|
183
182
|
self._initial_message = f'\n[bold red]{text2art(self._initial_message, font='tarty1')}\n\n'
|
184
183
|
self._farewell_message = (
|
185
184
|
f'[bold red]\n{text2art(f'\n{self._farewell_message}\n', font='chanky')}[/bold red]\n'
|
@@ -201,6 +200,7 @@ class AppSetups(AppValidators, AppPrinters):
|
|
201
200
|
|
202
201
|
for message in self._messages_on_startup:
|
203
202
|
self._print_func(message)
|
203
|
+
print('\n\n')
|
204
204
|
|
205
205
|
if not self._repeat_command_groups_description:
|
206
206
|
self._print_command_group_description()
|
@@ -253,9 +253,6 @@ class App(AppSetters, AppNonStandardHandlers, AppSetups):
|
|
253
253
|
|
254
254
|
|
255
255
|
def include_router(self, router: Router) -> None:
|
256
|
-
if not isinstance(router, Router):
|
257
|
-
raise InvalidRouterInstanceException()
|
258
|
-
|
259
256
|
router.set_ignore_command_register(self._ignore_command_register)
|
260
257
|
self._registered_routers.add_registered_router(router)
|
261
258
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: argenta
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.0b2
|
4
4
|
Summary: Python library for creating TUI
|
5
5
|
License: MIT
|
6
6
|
Author: kolo
|
@@ -22,7 +22,7 @@ Description-Content-Type: text/markdown
|
|
22
22
|
## Описание
|
23
23
|
**Argenta** — Python library for creating TUI
|
24
24
|
|
25
|
-

|
26
26
|
Пример внешнего вида TUI, написанного с помощью Argenta
|
27
27
|
|
28
28
|
---
|
@@ -112,16 +112,16 @@ def handler_with_flags(flags: InputFlags):
|
|
112
112
|
|
113
113
|
### Конструктор
|
114
114
|
```python
|
115
|
-
App(prompt: str = 'What do you want to do?\n',
|
116
|
-
initial_message: str = '
|
117
|
-
farewell_message: str = '
|
118
|
-
exit_command:
|
119
|
-
|
120
|
-
system_points_title: str = 'System points:',
|
115
|
+
App(prompt: str = '[italic dim bold]What do you want to do?\n',
|
116
|
+
initial_message: str = '\nArgenta\n',
|
117
|
+
farewell_message: str = '\nSee you\n',
|
118
|
+
exit_command: Command = Command('Q', 'Exit command'),
|
119
|
+
system_points_title: str | None = 'System points:',
|
121
120
|
ignore_command_register: bool = True,
|
122
121
|
dividing_line: StaticDividingLine | DynamicDividingLine = StaticDividingLine(),
|
123
122
|
repeat_command_groups: bool = True,
|
124
|
-
|
123
|
+
override_system_messages: bool = False,
|
124
|
+
autocompleter: AutoCompleter = AutoCompleter(),
|
125
125
|
print_func: Callable[[str], None] = Console().print)
|
126
126
|
```
|
127
127
|
**Аргументы:**
|
@@ -129,13 +129,13 @@ App(prompt: str = 'What do you want to do?\n',
|
|
129
129
|
- `prompt` (`str`): Сообщение перед вводом команды.
|
130
130
|
- `initial_message` (`str`): Приветственное сообщение при запуске.
|
131
131
|
- `farewell_message` (`str`): Сообщение при выходе.
|
132
|
-
- `exit_command` (`
|
133
|
-
- `exit_command_description` (`str`): Описание команды выхода.
|
132
|
+
- `exit_command` (`Command`): Сущность команды, которая будет отвечать за завершение работы.
|
134
133
|
- `system_points_title` (`str`): Заголовок перед списком системных команд.
|
135
134
|
- `ignore_command_register` (`bool`): Игнорировать регистр всех команд.
|
136
135
|
- `dividing_line` (`StaticDividingLine | DynamicDividingLine`): Разделительная строка.
|
137
136
|
- `repeat_command_groups` (`bool`): Повторять описание команд перед вводом.
|
138
|
-
- `
|
137
|
+
- `override_system_messages` (`bool`): Переопределить ли дефолтное оформление сообщений ([подробнее см.](#override_defaults))
|
138
|
+
- `autocompleter` (`AutoCompleter`): Сущность автодополнителя ввода.
|
139
139
|
- `print_func` (`Callable[[str], None]`): Функция вывода текста в терминал.
|
140
140
|
|
141
141
|
---
|
@@ -260,6 +260,26 @@ App(prompt: str = 'What do you want to do?\n',
|
|
260
260
|
|
261
261
|
---
|
262
262
|
|
263
|
+
## *class* :: `AutoCompleter`
|
264
|
+
Класс, экземпляр которого представляет собой автодополнитель ввода
|
265
|
+
|
266
|
+
### Конструктор
|
267
|
+
```python
|
268
|
+
AutoCompleter(history_filename: str = False,
|
269
|
+
autocomplete_button: str = 'tab')
|
270
|
+
```
|
271
|
+
|
272
|
+
**Аргументы:**
|
273
|
+
- **name : mean**
|
274
|
+
- `history_filename` (`str` | `False`): Путь к файлу, который будет являться или является
|
275
|
+
историй пользовательского ввода, в последующем эти команды будут автодополняться, файл
|
276
|
+
может не существовать при инициализации, тогда он будет создан, при значении аргумента `False`
|
277
|
+
история пользовательского ввода будет существовать только в пределах сессии и не сохраняться в файл
|
278
|
+
- `autocomplete_button` (`str`): Строковое обозначение кнопки на клавиатуре, которая будет
|
279
|
+
использоваться для автодополнения при вводе, по умолчанию `tab`
|
280
|
+
|
281
|
+
---
|
282
|
+
|
263
283
|
## *class* :: `StaticDivideLine`
|
264
284
|
Класс, экземпляр которого представляет собой строковый разделитель фиксированной длины
|
265
285
|
|
@@ -295,7 +315,7 @@ DinamicDivideLine(unit_part: str = '-')
|
|
295
315
|
|
296
316
|
### Конструктор
|
297
317
|
```python
|
298
|
-
Router(title: str
|
318
|
+
Router(title: str | None = None,
|
299
319
|
name: str = 'Default')
|
300
320
|
```
|
301
321
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
argenta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
argenta/app/__init__.py,sha256=I8FTXU17ajDI-hbC6Rw0LxLmvDYipdQaos3v1pmu14E,57
|
3
3
|
argenta/app/autocompleter/__init__.py,sha256=VT_p3QA78UnczV7pYR2NnwQ0Atd8mnDUnLazvUQNqJk,93
|
4
|
-
argenta/app/autocompleter/entity.py,sha256=
|
4
|
+
argenta/app/autocompleter/entity.py,sha256=6so4tFXbx45gNU0ZPq1jnIwsL4ieyfbz2qX15CFK2H4,1825
|
5
5
|
argenta/app/defaults.py,sha256=D0z9yGnfF8hhWUxHCvBhxTrxg6a9rPiySAn2Fyy7TXQ,311
|
6
6
|
argenta/app/dividing_line/__init__.py,sha256=jJZDDZix8XYCAUWW4FzGJH0JmJlchYcx0FPWifjgv1I,147
|
7
7
|
argenta/app/dividing_line/models.py,sha256=ueBDmy1hfYzGAr1X2G2Mw0hjES7YQBtP7N3TLBDz9h0,700
|
8
|
-
argenta/app/exceptions.py,sha256=
|
9
|
-
argenta/app/models.py,sha256=
|
8
|
+
argenta/app/exceptions.py,sha256=soGmLRxx4C3qCzidTN7H2RUbU4gkoIPRzR4BaaQYRmQ,345
|
9
|
+
argenta/app/models.py,sha256=YARJCxmW3iyvi5G-_u7y8cOqn7zPl72ypZL14pOFd_Y,12612
|
10
10
|
argenta/app/registered_routers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
11
|
argenta/app/registered_routers/entity.py,sha256=OQZyrF4eoCoDHzRJ22zZxhNEx-bOUDu7NZIFDfO-fuY,688
|
12
12
|
argenta/command/__init__.py,sha256=Plo2Da0fhq8H1eo2mg7nA1-OBLuGjK2BYpDGRvGGMIU,67
|
@@ -23,7 +23,7 @@ argenta/router/command_handlers/entity.py,sha256=KgFKjAMUr_mOcn9xahTxMUKB6lIxXgq
|
|
23
23
|
argenta/router/defaults.py,sha256=huftOg1HMjrT_R2SHHOL4eJ5uZHspNEYBSg-mCq9xhU,126
|
24
24
|
argenta/router/entity.py,sha256=d9S9Af9vACAgUaiPq-CgVGrb7KcAZYfYm3oavVAceI8,5900
|
25
25
|
argenta/router/exceptions.py,sha256=tdeaR8zDvnytgRYo_wQWKHt3if2brapgauIhhMIsTsA,678
|
26
|
-
argenta-0.5.
|
27
|
-
argenta-0.5.
|
28
|
-
argenta-0.5.
|
29
|
-
argenta-0.5.
|
26
|
+
argenta-0.5.0b2.dist-info/LICENSE,sha256=zmqoGh2n5rReBv4s8wPxF_gZEZDgauJYSPMuPczgOiU,1082
|
27
|
+
argenta-0.5.0b2.dist-info/METADATA,sha256=faOX-yS54kMog4BVaYP0gQTLOa8UTvLqNVAXLR2ULr4,22345
|
28
|
+
argenta-0.5.0b2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
29
|
+
argenta-0.5.0b2.dist-info/RECORD,,
|
File without changes
|