hspylib-clitt 0.9.120__py3-none-any.whl → 0.9.121__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.
Potentially problematic release.
This version of hspylib-clitt might be problematic. Click here for more details.
- clitt/.version +1 -1
- clitt/__init__.py +3 -3
- clitt/addons/__init__.py +3 -3
- clitt/addons/appman/__init__.py +3 -3
- clitt/addons/appman/templates/__init__.py +3 -3
- clitt/addons/widman/__init__.py +3 -3
- clitt/addons/widman/widgets/__init__.py +3 -3
- clitt/core/__init__.py +3 -3
- clitt/core/exception/__init__.py +3 -3
- clitt/core/icons/__init__.py +3 -3
- clitt/core/icons/emojis/__init__.py +3 -3
- clitt/core/icons/font_awesome/__init__.py +3 -3
- clitt/core/term/__init__.py +3 -3
- clitt/core/tui/__init__.py +3 -3
- clitt/core/tui/line_input/__init__.py +3 -3
- clitt/core/tui/line_input/keyboard_input.py +70 -63
- clitt/core/tui/mchoose/__init__.py +3 -3
- clitt/core/tui/mdashboard/__init__.py +3 -3
- clitt/core/tui/menu/__init__.py +3 -3
- clitt/core/tui/minput/__init__.py +3 -3
- clitt/core/tui/minput/menu_input.py +7 -15
- clitt/core/tui/mselect/__init__.py +3 -3
- clitt/core/tui/table/__init__.py +3 -3
- clitt/utils/__init__.py +3 -3
- {hspylib_clitt-0.9.120.dist-info → hspylib_clitt-0.9.121.dist-info}/METADATA +2 -2
- hspylib_clitt-0.9.121.dist-info/RECORD +97 -0
- {hspylib_clitt-0.9.120.dist-info → hspylib_clitt-0.9.121.dist-info}/top_level.txt +0 -1
- build/lib/build/lib/build/lib/clitt/__classpath__.py +0 -28
- build/lib/build/lib/build/lib/clitt/__init__.py +0 -13
- build/lib/build/lib/build/lib/clitt/__main__.py +0 -139
- build/lib/build/lib/build/lib/clitt/addons/__init__.py +0 -12
- build/lib/build/lib/build/lib/clitt/addons/appman/__init__.py +0 -13
- build/lib/build/lib/build/lib/clitt/addons/appman/appman.py +0 -305
- build/lib/build/lib/build/lib/clitt/addons/appman/appman_enums.py +0 -39
- build/lib/build/lib/build/lib/clitt/addons/appman/templates/__init__.py +0 -11
- build/lib/build/lib/build/lib/clitt/addons/widman/__init__.py +0 -14
- build/lib/build/lib/build/lib/clitt/addons/widman/widget.py +0 -70
- build/lib/build/lib/build/lib/clitt/addons/widman/widget_entry.py +0 -54
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/__init__.py +0 -14
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_free.py +0 -110
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_punch.py +0 -246
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_send_msg.py +0 -272
- build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_time_calc.py +0 -146
- build/lib/build/lib/build/lib/clitt/addons/widman/widman.py +0 -123
- build/lib/build/lib/build/lib/clitt/core/__init__.py +0 -15
- build/lib/build/lib/build/lib/clitt/core/exception/__init__.py +0 -11
- build/lib/build/lib/build/lib/clitt/core/exception/exceptions.py +0 -19
- build/lib/build/lib/build/lib/clitt/core/icons/__init__.py +0 -12
- build/lib/build/lib/build/lib/clitt/core/icons/emojis/__init__.py +0 -12
- build/lib/build/lib/build/lib/clitt/core/icons/emojis/emojis.py +0 -41
- build/lib/build/lib/build/lib/clitt/core/icons/emojis/face_smiling.py +0 -40
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/__init__.py +0 -18
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/app_icons.py +0 -55
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/awesome.py +0 -76
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +0 -93
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/form_icons.py +0 -69
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/game_icons.py +0 -59
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/nav_icons.py +0 -42
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +0 -39
- build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/widget_icons.py +0 -37
- build/lib/build/lib/build/lib/clitt/core/preferences.py +0 -87
- build/lib/build/lib/build/lib/clitt/core/term/__init__.py +0 -14
- build/lib/build/lib/build/lib/clitt/core/term/commons.py +0 -106
- build/lib/build/lib/build/lib/clitt/core/term/cursor.py +0 -174
- build/lib/build/lib/build/lib/clitt/core/term/screen.py +0 -106
- build/lib/build/lib/build/lib/clitt/core/term/terminal.py +0 -202
- build/lib/build/lib/build/lib/clitt/core/tui/__init__.py +0 -20
- build/lib/build/lib/build/lib/clitt/core/tui/line_input/__init__.py +0 -12
- build/lib/build/lib/build/lib/clitt/core/tui/line_input/keyboard_input.py +0 -229
- build/lib/build/lib/build/lib/clitt/core/tui/line_input/line_input.py +0 -31
- build/lib/build/lib/build/lib/clitt/core/tui/mchoose/__init__.py +0 -12
- build/lib/build/lib/build/lib/clitt/core/tui/mchoose/mchoose.py +0 -43
- build/lib/build/lib/build/lib/clitt/core/tui/mchoose/menu_choose.py +0 -192
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/__init__.py +0 -14
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +0 -54
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_item.py +0 -31
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/mdashboard.py +0 -26
- build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +0 -148
- build/lib/build/lib/build/lib/clitt/core/tui/menu/__init__.py +0 -16
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu.py +0 -111
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_action.py +0 -47
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_factory.py +0 -117
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_item.py +0 -196
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_ui.py +0 -98
- build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_view.py +0 -57
- build/lib/build/lib/build/lib/clitt/core/tui/minput/__init__.py +0 -19
- build/lib/build/lib/build/lib/clitt/core/tui/minput/access_type.py +0 -26
- build/lib/build/lib/build/lib/clitt/core/tui/minput/field_builder.py +0 -117
- build/lib/build/lib/build/lib/clitt/core/tui/minput/form_builder.py +0 -72
- build/lib/build/lib/build/lib/clitt/core/tui/minput/form_field.py +0 -180
- build/lib/build/lib/build/lib/clitt/core/tui/minput/input_type.py +0 -30
- build/lib/build/lib/build/lib/clitt/core/tui/minput/input_validator.py +0 -98
- build/lib/build/lib/build/lib/clitt/core/tui/minput/menu_input.py +0 -292
- build/lib/build/lib/build/lib/clitt/core/tui/minput/minput.py +0 -44
- build/lib/build/lib/build/lib/clitt/core/tui/minput/minput_utils.py +0 -156
- build/lib/build/lib/build/lib/clitt/core/tui/mselect/__init__.py +0 -12
- build/lib/build/lib/build/lib/clitt/core/tui/mselect/menu_select.py +0 -170
- build/lib/build/lib/build/lib/clitt/core/tui/mselect/mselect.py +0 -36
- build/lib/build/lib/build/lib/clitt/core/tui/table/__init__.py +0 -12
- build/lib/build/lib/build/lib/clitt/core/tui/table/table_enums.py +0 -47
- build/lib/build/lib/build/lib/clitt/core/tui/table/table_renderer.py +0 -339
- build/lib/build/lib/build/lib/clitt/core/tui/tui_application.py +0 -52
- build/lib/build/lib/build/lib/clitt/core/tui/tui_component.py +0 -154
- build/lib/build/lib/build/lib/clitt/core/tui/tui_preferences.py +0 -103
- build/lib/build/lib/build/lib/clitt/utils/__init__.py +0 -11
- build/lib/build/lib/build/lib/clitt/utils/git_utils.py +0 -66
- build/lib/build/lib/clitt/__classpath__.py +0 -28
- build/lib/build/lib/clitt/__init__.py +0 -13
- build/lib/build/lib/clitt/__main__.py +0 -139
- build/lib/build/lib/clitt/addons/__init__.py +0 -12
- build/lib/build/lib/clitt/addons/appman/__init__.py +0 -13
- build/lib/build/lib/clitt/addons/appman/appman.py +0 -305
- build/lib/build/lib/clitt/addons/appman/appman_enums.py +0 -39
- build/lib/build/lib/clitt/addons/appman/templates/__init__.py +0 -11
- build/lib/build/lib/clitt/addons/widman/__init__.py +0 -14
- build/lib/build/lib/clitt/addons/widman/widget.py +0 -70
- build/lib/build/lib/clitt/addons/widman/widget_entry.py +0 -54
- build/lib/build/lib/clitt/addons/widman/widgets/__init__.py +0 -14
- build/lib/build/lib/clitt/addons/widman/widgets/widget_free.py +0 -110
- build/lib/build/lib/clitt/addons/widman/widgets/widget_punch.py +0 -246
- build/lib/build/lib/clitt/addons/widman/widgets/widget_send_msg.py +0 -272
- build/lib/build/lib/clitt/addons/widman/widgets/widget_time_calc.py +0 -146
- build/lib/build/lib/clitt/addons/widman/widman.py +0 -123
- build/lib/build/lib/clitt/core/__init__.py +0 -15
- build/lib/build/lib/clitt/core/exception/__init__.py +0 -11
- build/lib/build/lib/clitt/core/exception/exceptions.py +0 -19
- build/lib/build/lib/clitt/core/icons/__init__.py +0 -12
- build/lib/build/lib/clitt/core/icons/emojis/__init__.py +0 -12
- build/lib/build/lib/clitt/core/icons/emojis/emojis.py +0 -41
- build/lib/build/lib/clitt/core/icons/emojis/face_smiling.py +0 -40
- build/lib/build/lib/clitt/core/icons/font_awesome/__init__.py +0 -18
- build/lib/build/lib/clitt/core/icons/font_awesome/app_icons.py +0 -55
- build/lib/build/lib/clitt/core/icons/font_awesome/awesome.py +0 -76
- build/lib/build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +0 -93
- build/lib/build/lib/clitt/core/icons/font_awesome/form_icons.py +0 -69
- build/lib/build/lib/clitt/core/icons/font_awesome/game_icons.py +0 -59
- build/lib/build/lib/clitt/core/icons/font_awesome/nav_icons.py +0 -42
- build/lib/build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +0 -39
- build/lib/build/lib/clitt/core/icons/font_awesome/widget_icons.py +0 -37
- build/lib/build/lib/clitt/core/preferences.py +0 -87
- build/lib/build/lib/clitt/core/term/__init__.py +0 -14
- build/lib/build/lib/clitt/core/term/commons.py +0 -106
- build/lib/build/lib/clitt/core/term/cursor.py +0 -174
- build/lib/build/lib/clitt/core/term/screen.py +0 -106
- build/lib/build/lib/clitt/core/term/terminal.py +0 -202
- build/lib/build/lib/clitt/core/tui/__init__.py +0 -20
- build/lib/build/lib/clitt/core/tui/line_input/__init__.py +0 -12
- build/lib/build/lib/clitt/core/tui/line_input/keyboard_input.py +0 -229
- build/lib/build/lib/clitt/core/tui/line_input/line_input.py +0 -31
- build/lib/build/lib/clitt/core/tui/mchoose/__init__.py +0 -12
- build/lib/build/lib/clitt/core/tui/mchoose/mchoose.py +0 -43
- build/lib/build/lib/clitt/core/tui/mchoose/menu_choose.py +0 -192
- build/lib/build/lib/clitt/core/tui/mdashboard/__init__.py +0 -14
- build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +0 -54
- build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_item.py +0 -31
- build/lib/build/lib/clitt/core/tui/mdashboard/mdashboard.py +0 -26
- build/lib/build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +0 -148
- build/lib/build/lib/clitt/core/tui/menu/__init__.py +0 -16
- build/lib/build/lib/clitt/core/tui/menu/tui_menu.py +0 -111
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_action.py +0 -47
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_factory.py +0 -117
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_item.py +0 -196
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_ui.py +0 -98
- build/lib/build/lib/clitt/core/tui/menu/tui_menu_view.py +0 -57
- build/lib/build/lib/clitt/core/tui/minput/__init__.py +0 -19
- build/lib/build/lib/clitt/core/tui/minput/access_type.py +0 -26
- build/lib/build/lib/clitt/core/tui/minput/field_builder.py +0 -117
- build/lib/build/lib/clitt/core/tui/minput/form_builder.py +0 -72
- build/lib/build/lib/clitt/core/tui/minput/form_field.py +0 -180
- build/lib/build/lib/clitt/core/tui/minput/input_type.py +0 -30
- build/lib/build/lib/clitt/core/tui/minput/input_validator.py +0 -98
- build/lib/build/lib/clitt/core/tui/minput/menu_input.py +0 -292
- build/lib/build/lib/clitt/core/tui/minput/minput.py +0 -44
- build/lib/build/lib/clitt/core/tui/minput/minput_utils.py +0 -156
- build/lib/build/lib/clitt/core/tui/mselect/__init__.py +0 -12
- build/lib/build/lib/clitt/core/tui/mselect/menu_select.py +0 -170
- build/lib/build/lib/clitt/core/tui/mselect/mselect.py +0 -36
- build/lib/build/lib/clitt/core/tui/table/__init__.py +0 -12
- build/lib/build/lib/clitt/core/tui/table/table_enums.py +0 -47
- build/lib/build/lib/clitt/core/tui/table/table_renderer.py +0 -339
- build/lib/build/lib/clitt/core/tui/tui_application.py +0 -52
- build/lib/build/lib/clitt/core/tui/tui_component.py +0 -154
- build/lib/build/lib/clitt/core/tui/tui_preferences.py +0 -103
- build/lib/build/lib/clitt/utils/__init__.py +0 -11
- build/lib/build/lib/clitt/utils/git_utils.py +0 -66
- build/lib/clitt/__classpath__.py +0 -28
- build/lib/clitt/__init__.py +0 -13
- build/lib/clitt/__main__.py +0 -139
- build/lib/clitt/addons/__init__.py +0 -12
- build/lib/clitt/addons/appman/__init__.py +0 -13
- build/lib/clitt/addons/appman/appman.py +0 -305
- build/lib/clitt/addons/appman/appman_enums.py +0 -39
- build/lib/clitt/addons/appman/templates/__init__.py +0 -11
- build/lib/clitt/addons/widman/__init__.py +0 -14
- build/lib/clitt/addons/widman/widget.py +0 -70
- build/lib/clitt/addons/widman/widget_entry.py +0 -54
- build/lib/clitt/addons/widman/widgets/__init__.py +0 -14
- build/lib/clitt/addons/widman/widgets/widget_free.py +0 -110
- build/lib/clitt/addons/widman/widgets/widget_punch.py +0 -246
- build/lib/clitt/addons/widman/widgets/widget_send_msg.py +0 -272
- build/lib/clitt/addons/widman/widgets/widget_time_calc.py +0 -146
- build/lib/clitt/addons/widman/widman.py +0 -123
- build/lib/clitt/core/__init__.py +0 -15
- build/lib/clitt/core/exception/__init__.py +0 -11
- build/lib/clitt/core/exception/exceptions.py +0 -19
- build/lib/clitt/core/icons/__init__.py +0 -12
- build/lib/clitt/core/icons/emojis/__init__.py +0 -12
- build/lib/clitt/core/icons/emojis/emojis.py +0 -41
- build/lib/clitt/core/icons/emojis/face_smiling.py +0 -40
- build/lib/clitt/core/icons/font_awesome/__init__.py +0 -18
- build/lib/clitt/core/icons/font_awesome/app_icons.py +0 -55
- build/lib/clitt/core/icons/font_awesome/awesome.py +0 -76
- build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +0 -93
- build/lib/clitt/core/icons/font_awesome/form_icons.py +0 -69
- build/lib/clitt/core/icons/font_awesome/game_icons.py +0 -59
- build/lib/clitt/core/icons/font_awesome/nav_icons.py +0 -42
- build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +0 -39
- build/lib/clitt/core/icons/font_awesome/widget_icons.py +0 -37
- build/lib/clitt/core/preferences.py +0 -87
- build/lib/clitt/core/term/__init__.py +0 -14
- build/lib/clitt/core/term/commons.py +0 -106
- build/lib/clitt/core/term/cursor.py +0 -174
- build/lib/clitt/core/term/screen.py +0 -106
- build/lib/clitt/core/term/terminal.py +0 -202
- build/lib/clitt/core/tui/__init__.py +0 -20
- build/lib/clitt/core/tui/line_input/__init__.py +0 -12
- build/lib/clitt/core/tui/line_input/keyboard_input.py +0 -229
- build/lib/clitt/core/tui/line_input/line_input.py +0 -31
- build/lib/clitt/core/tui/mchoose/__init__.py +0 -12
- build/lib/clitt/core/tui/mchoose/mchoose.py +0 -43
- build/lib/clitt/core/tui/mchoose/menu_choose.py +0 -192
- build/lib/clitt/core/tui/mdashboard/__init__.py +0 -14
- build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +0 -54
- build/lib/clitt/core/tui/mdashboard/dashboard_item.py +0 -31
- build/lib/clitt/core/tui/mdashboard/mdashboard.py +0 -26
- build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +0 -148
- build/lib/clitt/core/tui/menu/__init__.py +0 -16
- build/lib/clitt/core/tui/menu/tui_menu.py +0 -111
- build/lib/clitt/core/tui/menu/tui_menu_action.py +0 -47
- build/lib/clitt/core/tui/menu/tui_menu_factory.py +0 -117
- build/lib/clitt/core/tui/menu/tui_menu_item.py +0 -196
- build/lib/clitt/core/tui/menu/tui_menu_ui.py +0 -98
- build/lib/clitt/core/tui/menu/tui_menu_view.py +0 -57
- build/lib/clitt/core/tui/minput/__init__.py +0 -19
- build/lib/clitt/core/tui/minput/access_type.py +0 -26
- build/lib/clitt/core/tui/minput/field_builder.py +0 -117
- build/lib/clitt/core/tui/minput/form_builder.py +0 -72
- build/lib/clitt/core/tui/minput/form_field.py +0 -180
- build/lib/clitt/core/tui/minput/input_type.py +0 -30
- build/lib/clitt/core/tui/minput/input_validator.py +0 -98
- build/lib/clitt/core/tui/minput/menu_input.py +0 -292
- build/lib/clitt/core/tui/minput/minput.py +0 -44
- build/lib/clitt/core/tui/minput/minput_utils.py +0 -156
- build/lib/clitt/core/tui/mselect/__init__.py +0 -12
- build/lib/clitt/core/tui/mselect/menu_select.py +0 -170
- build/lib/clitt/core/tui/mselect/mselect.py +0 -36
- build/lib/clitt/core/tui/table/__init__.py +0 -12
- build/lib/clitt/core/tui/table/table_enums.py +0 -47
- build/lib/clitt/core/tui/table/table_renderer.py +0 -339
- build/lib/clitt/core/tui/tui_application.py +0 -52
- build/lib/clitt/core/tui/tui_component.py +0 -154
- build/lib/clitt/core/tui/tui_preferences.py +0 -103
- build/lib/clitt/utils/__init__.py +0 -11
- build/lib/clitt/utils/git_utils.py +0 -66
- hspylib_clitt-0.9.120.dist-info/RECORD +0 -334
- {hspylib_clitt-0.9.120.dist-info → hspylib_clitt-0.9.121.dist-info}/WHEEL +0 -0
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.minput
|
|
7
|
-
@file: minput.py
|
|
8
|
-
@created: Tue, 4 May 2021
|
|
9
|
-
@author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior"
|
|
10
|
-
@site: https://github.com/yorevs/hspylib
|
|
11
|
-
@license: MIT - Please refer to <https://opensource.org/licenses/MIT>
|
|
12
|
-
|
|
13
|
-
Copyright·(c)·2024,·HSPyLib
|
|
14
|
-
"""
|
|
15
|
-
from clitt.core.tui.minput.form_field import FormField
|
|
16
|
-
from clitt.core.tui.minput.menu_input import MenuInput
|
|
17
|
-
from hspylib.core.enums.charset import Charset
|
|
18
|
-
from hspylib.core.namespace import Namespace
|
|
19
|
-
from hspylib.core.preconditions import check_argument
|
|
20
|
-
from hspylib.core.tools.text_tools import quote, snakecase
|
|
21
|
-
from typing import List, Optional
|
|
22
|
-
|
|
23
|
-
import os
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def minput(
|
|
27
|
-
form_fields: List[FormField], title: str = "Please fill all fields of the form fields below", output: str = None
|
|
28
|
-
) -> Optional[Namespace]:
|
|
29
|
-
"""
|
|
30
|
-
Terminal UI menu form input method.
|
|
31
|
-
:param form_fields: the provided form items to input from.
|
|
32
|
-
:param title: the title to be displayed before the form.
|
|
33
|
-
:param output: optional output file containing the marked items.
|
|
34
|
-
:return: a namespace containing all form values.
|
|
35
|
-
"""
|
|
36
|
-
check_argument(len(form_fields) > 0, "Must provide at least one form field!")
|
|
37
|
-
result = MenuInput(title, form_fields).execute()
|
|
38
|
-
|
|
39
|
-
if result and output:
|
|
40
|
-
with open(output, "w", encoding=Charset.UTF_8.val) as f_out:
|
|
41
|
-
for name, value in zip(result.attributes, result.values):
|
|
42
|
-
f_out.write(f"{snakecase(name, screaming=True)}={quote(value)}" + os.linesep)
|
|
43
|
-
|
|
44
|
-
return result
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.minput
|
|
7
|
-
@file: minput_utils.py
|
|
8
|
-
@created: Thu, 20 May 2021
|
|
9
|
-
@author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior"
|
|
10
|
-
@site: https://github.com/yorevs/hspylib
|
|
11
|
-
@license: MIT - Please refer to <https://opensource.org/licenses/MIT>
|
|
12
|
-
|
|
13
|
-
Copyright·(c)·2024,·HSPyLib
|
|
14
|
-
"""
|
|
15
|
-
from clitt.core.term.screen import Screen
|
|
16
|
-
from hspylib.core.exception.exceptions import InvalidInputError
|
|
17
|
-
from typing import Any, Optional, Tuple
|
|
18
|
-
|
|
19
|
-
import re
|
|
20
|
-
|
|
21
|
-
MASK_SYMBOLS = ["#", "@", "%", "*"]
|
|
22
|
-
|
|
23
|
-
VALUE_SEPARATORS = r"[|,;]"
|
|
24
|
-
|
|
25
|
-
VALUE_SELECTORS = r"[<>]"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def detail_len(field: Any) -> int:
|
|
29
|
-
"""Return the length of the details, according to the form field.
|
|
30
|
-
:param field: the form field to get details.
|
|
31
|
-
"""
|
|
32
|
-
max_len = len(str(field.max_length))
|
|
33
|
-
return 1 + (2 * max_len)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def mi_print(screen: Screen, text: str, prefix: str = None, field_len: int = 0, end: str = "") -> None:
|
|
37
|
-
"""Special menu input print.
|
|
38
|
-
:param screen: the component's screen.
|
|
39
|
-
:param text: the text to be printed.
|
|
40
|
-
:param prefix the text to print before the text.
|
|
41
|
-
:param field_len: the length of the field.
|
|
42
|
-
:param end: string appended after the last value, default an empty string.
|
|
43
|
-
"""
|
|
44
|
-
fmt = ("{}" if prefix else "") + "{:<" + str(field_len) + "} : "
|
|
45
|
-
if prefix:
|
|
46
|
-
screen.cursor.write(fmt.format(prefix, text), end=end)
|
|
47
|
-
else:
|
|
48
|
-
screen.cursor.write(fmt.format(text or ""), end=end)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def mi_print_err(screen: Screen, text: str) -> None:
|
|
52
|
-
"""Special menu input print error message.
|
|
53
|
-
:param screen: the component's screen.
|
|
54
|
-
:param text: the text to be printed.
|
|
55
|
-
"""
|
|
56
|
-
screen.cursor.write(f"%RED%{text}%NC%")
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def toggle_selected(tokenized_values: str) -> str:
|
|
60
|
-
"""Toggle the 'select' component value. Selects the next value on the token sequence.
|
|
61
|
-
:param tokenized_values: the 'select' component tokenized values.
|
|
62
|
-
"""
|
|
63
|
-
values = re.split(VALUE_SEPARATORS, tokenized_values)
|
|
64
|
-
cur_idx = next((idx for idx, val in enumerate(values) if val.find("<") >= 0), -1)
|
|
65
|
-
if cur_idx < 0:
|
|
66
|
-
if len(values) > 1:
|
|
67
|
-
values[1] = f"<{values[1]}>"
|
|
68
|
-
else:
|
|
69
|
-
values[0] = f"<{values[0]}>"
|
|
70
|
-
return "|".join(values)
|
|
71
|
-
unselected = list(map(lambda x: re.sub(VALUE_SELECTORS, "", x), values))
|
|
72
|
-
# fmt: off
|
|
73
|
-
return '|'.join([
|
|
74
|
-
f'<{val}>'
|
|
75
|
-
if idx == (cur_idx + 1) or ((cur_idx + 1) >= len(unselected) and idx == 0)
|
|
76
|
-
else val for idx, val in enumerate(unselected)
|
|
77
|
-
])
|
|
78
|
-
# fmt: on
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
def get_selected(tokenized_values: str) -> Optional[Tuple[int, str]]:
|
|
82
|
-
"""Get the selected value from the 'select' component tokens.
|
|
83
|
-
:param tokenized_values: the 'select' component tokenized values.
|
|
84
|
-
"""
|
|
85
|
-
values = re.split(VALUE_SEPARATORS, tokenized_values)
|
|
86
|
-
# fmt: off
|
|
87
|
-
sel_item = next((
|
|
88
|
-
re.sub(VALUE_SELECTORS, '', val)
|
|
89
|
-
for val in values if val.startswith('<') and val.endswith('>')
|
|
90
|
-
), values[0])
|
|
91
|
-
# fmt: on
|
|
92
|
-
try:
|
|
93
|
-
return values.index(sel_item), sel_item
|
|
94
|
-
except ValueError:
|
|
95
|
-
try:
|
|
96
|
-
return values.index(f"<{sel_item}>"), sel_item
|
|
97
|
-
except ValueError:
|
|
98
|
-
return -1, sel_item
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def unpack_masked(value: str) -> Tuple[str, str]:
|
|
102
|
-
"""Unpack all values of the 'masked' component.
|
|
103
|
-
:param value: the masked values to unpack.
|
|
104
|
-
"""
|
|
105
|
-
if value:
|
|
106
|
-
parts = re.split(VALUE_SEPARATORS, value)
|
|
107
|
-
return parts[0], parts[1] if len(parts) == 2 else ""
|
|
108
|
-
|
|
109
|
-
return "", ""
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def append_masked(value: str, mask: str, keypress_value: chr) -> str:
|
|
113
|
-
"""Append a value to the masked field.
|
|
114
|
-
:param value: the masked field current value.
|
|
115
|
-
:param mask: the masked field's mask.
|
|
116
|
-
:param keypress_value: the value to append (it can be a part of the mask itself).
|
|
117
|
-
"""
|
|
118
|
-
idx = len(value)
|
|
119
|
-
masked_value = value
|
|
120
|
-
if idx < len(mask):
|
|
121
|
-
if keypress_value == mask[idx]:
|
|
122
|
-
return f"{value}{keypress_value}|{mask}"
|
|
123
|
-
while idx < len(mask) and mask[idx] not in MASK_SYMBOLS:
|
|
124
|
-
masked_value += mask[idx]
|
|
125
|
-
idx += 1
|
|
126
|
-
if mask and idx < len(mask):
|
|
127
|
-
mask_re = mask_regex(mask, idx)
|
|
128
|
-
if re.search(mask_re, keypress_value):
|
|
129
|
-
masked_value += keypress_value
|
|
130
|
-
else:
|
|
131
|
-
raise InvalidInputError(f"Value '{keypress_value}' is invalid. Expecting: {mask_re}")
|
|
132
|
-
|
|
133
|
-
return f"{masked_value}|{mask}"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def over_masked(value: str, mask: str) -> str:
|
|
137
|
-
"""
|
|
138
|
-
Return the value to be printed by a 'masked' input field. A placeholder value will be used for unfilled values.
|
|
139
|
-
:param value: the masked field current value.
|
|
140
|
-
:param mask: the masked field's mask.
|
|
141
|
-
"""
|
|
142
|
-
if value:
|
|
143
|
-
over_masked_val = ""
|
|
144
|
-
for idx, element in enumerate(mask):
|
|
145
|
-
if element in MASK_SYMBOLS:
|
|
146
|
-
over_masked_val += value[idx] if idx < len(value) else mask[idx]
|
|
147
|
-
else:
|
|
148
|
-
over_masked_val += element
|
|
149
|
-
return over_masked_val
|
|
150
|
-
|
|
151
|
-
return mask
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
def mask_regex(mask: str, idx: int) -> str:
|
|
155
|
-
"""Return a regex matching the index of the mask."""
|
|
156
|
-
return mask[idx].replace("#", "[0-9]").replace("@", "[a-zA-Z]").replace("%", "[a-zA-Z0-9]").replace("*", ".")
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.mselect
|
|
7
|
-
@file: menu_select.py
|
|
8
|
-
@created: Wed, 17 May 2023
|
|
9
|
-
@author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior"
|
|
10
|
-
@site: https://github.com/yorevs/hspylib
|
|
11
|
-
@license: MIT - Please refer to <https://opensource.org/licenses/MIT>
|
|
12
|
-
|
|
13
|
-
Copyright·(c)·2024,·HSPyLib
|
|
14
|
-
"""
|
|
15
|
-
from clitt.core.icons.font_awesome.nav_icons import NavIcons
|
|
16
|
-
from clitt.core.term.commons import Direction, Portion
|
|
17
|
-
from clitt.core.tui.tui_component import TUIComponent
|
|
18
|
-
from hspylib.modules.cli.keyboard import Keyboard
|
|
19
|
-
from typing import List, Optional, TypeAlias, TypeVar
|
|
20
|
-
|
|
21
|
-
T = TypeVar("T")
|
|
22
|
-
|
|
23
|
-
MSelectItems: TypeAlias = List[T]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class MenuSelect(TUIComponent):
|
|
27
|
-
"""Terminal UI menu select input method"""
|
|
28
|
-
|
|
29
|
-
NAV_ICONS = NavIcons.compose(NavIcons.UP, NavIcons.DOWN)
|
|
30
|
-
|
|
31
|
-
ROW_OFFSET = 5
|
|
32
|
-
|
|
33
|
-
MIN_ROWS = 3
|
|
34
|
-
|
|
35
|
-
def __init__(self, title: str, items: MSelectItems):
|
|
36
|
-
super().__init__(title)
|
|
37
|
-
self._items = items
|
|
38
|
-
self._show_from = 0
|
|
39
|
-
self._show_to = self._max_rows()
|
|
40
|
-
self._diff_index = self._show_to - self._show_from
|
|
41
|
-
self._sel_index = 0
|
|
42
|
-
self._max_line_length = max(len(str(item)) for item in items)
|
|
43
|
-
|
|
44
|
-
def execute(self) -> Optional[T]:
|
|
45
|
-
"""Execute the component's main flow."""
|
|
46
|
-
|
|
47
|
-
if (length := len(self._items)) == 0:
|
|
48
|
-
return None
|
|
49
|
-
if length == 1: # When only one option is provided, select the element at index 0 and return
|
|
50
|
-
return self._items[0]
|
|
51
|
-
|
|
52
|
-
self._prepare_render()
|
|
53
|
-
keypress = self._loop()
|
|
54
|
-
|
|
55
|
-
return self._items[self._sel_index] if keypress.isEnter() else None
|
|
56
|
-
|
|
57
|
-
def render(self) -> None:
|
|
58
|
-
"""Renders the TUI component."""
|
|
59
|
-
|
|
60
|
-
length = len(self._items)
|
|
61
|
-
self.cursor.restore()
|
|
62
|
-
self.writeln(f"{self.prefs.title_color.placeholder}{self.title}%EOL%%NC%")
|
|
63
|
-
|
|
64
|
-
for idx in range(self._show_from, self._show_to):
|
|
65
|
-
if idx >= length:
|
|
66
|
-
break # When the index is greater than the number of items, stop rendering
|
|
67
|
-
|
|
68
|
-
option_line = str(self._items[idx])
|
|
69
|
-
self.cursor.erase(Portion.LINE)
|
|
70
|
-
# Print the selector if the index is currently selected
|
|
71
|
-
selector = self.draw_selector(idx == self._sel_index)
|
|
72
|
-
# fmt: off
|
|
73
|
-
line_fmt = (
|
|
74
|
-
" {:>" + f"{len(str(length))}" + "} "
|
|
75
|
-
+ "{:>" + f"{len(selector)}" + "} "
|
|
76
|
-
+ "{:<" + f"{self._max_line_length}" + "} "
|
|
77
|
-
)
|
|
78
|
-
# fmt: on
|
|
79
|
-
self.draw_line(line_fmt, idx + 1, selector, option_line)
|
|
80
|
-
|
|
81
|
-
self.draw_navbar(self.navbar(to=length))
|
|
82
|
-
self._re_render = False
|
|
83
|
-
|
|
84
|
-
def navbar(self, **kwargs) -> str:
|
|
85
|
-
return (
|
|
86
|
-
f"%EOL%{self.prefs.navbar_color.placeholder}"
|
|
87
|
-
f"[Enter] Select [{self.NAV_ICONS}] "
|
|
88
|
-
f"Navigate [Esc] Quit [1..{kwargs['to']}] Goto: %NC%"
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
def handle_keypress(self) -> Keyboard:
|
|
92
|
-
if keypress := Keyboard.wait_keystroke():
|
|
93
|
-
match keypress:
|
|
94
|
-
case _ as key if key in Keyboard.break_keys():
|
|
95
|
-
self._done = True
|
|
96
|
-
case Keyboard.VK_UP:
|
|
97
|
-
self._handle_key_up()
|
|
98
|
-
case Keyboard.VK_DOWN:
|
|
99
|
-
self._handle_key_down()
|
|
100
|
-
case Keyboard.VK_TAB:
|
|
101
|
-
self._handle_tab()
|
|
102
|
-
case Keyboard.VK_SHIFT_TAB:
|
|
103
|
-
self._handle_shift_tab()
|
|
104
|
-
case _ as key if key in Keyboard.digits():
|
|
105
|
-
self._handle_digit(keypress)
|
|
106
|
-
|
|
107
|
-
return keypress
|
|
108
|
-
|
|
109
|
-
def _handle_digit(self, digit: Keyboard) -> None:
|
|
110
|
-
"""TODO"""
|
|
111
|
-
length = len(self._items)
|
|
112
|
-
typed_index = digit.value
|
|
113
|
-
self.cursor.write(f"{digit.value}") # echo the digit typed
|
|
114
|
-
index_len = 1
|
|
115
|
-
while len(typed_index) < len(str(length)):
|
|
116
|
-
keystroke = Keyboard.wait_keystroke()
|
|
117
|
-
if not keystroke or not keystroke.isdigit():
|
|
118
|
-
typed_index = None if keystroke != Keyboard.VK_ENTER else typed_index
|
|
119
|
-
break
|
|
120
|
-
typed_index = f"{typed_index}{keystroke.value if keystroke else ''}"
|
|
121
|
-
self.cursor.write(f"{keystroke.value if keystroke else ''}")
|
|
122
|
-
index_len += 1
|
|
123
|
-
# Erase the index typed by the user
|
|
124
|
-
self.cursor.move(index_len, Direction.LEFT)
|
|
125
|
-
self.cursor.erase(Direction.RIGHT)
|
|
126
|
-
if typed_index and 1 <= int(typed_index) <= length:
|
|
127
|
-
self._show_to = max(int(typed_index), self._diff_index)
|
|
128
|
-
self._show_from = self._show_to - self._diff_index
|
|
129
|
-
self._sel_index = int(typed_index) - 1
|
|
130
|
-
self._re_render = True
|
|
131
|
-
|
|
132
|
-
def _handle_key_up(self) -> None:
|
|
133
|
-
"""TODO"""
|
|
134
|
-
if self._sel_index == self._show_from and self._show_from > 0:
|
|
135
|
-
self._show_from -= 1
|
|
136
|
-
self._show_to -= 1
|
|
137
|
-
if self._sel_index - 1 >= 0:
|
|
138
|
-
self._sel_index -= 1
|
|
139
|
-
self._re_render = True
|
|
140
|
-
|
|
141
|
-
def _handle_key_down(self) -> None:
|
|
142
|
-
"""TODO"""
|
|
143
|
-
length = len(self._items)
|
|
144
|
-
if self._sel_index + 1 == self._show_to and self._show_to < length:
|
|
145
|
-
self._show_from += 1
|
|
146
|
-
self._show_to += 1
|
|
147
|
-
if self._sel_index + 1 < length:
|
|
148
|
-
self._sel_index += 1
|
|
149
|
-
self._re_render = True
|
|
150
|
-
|
|
151
|
-
def _handle_tab(self) -> None:
|
|
152
|
-
"""TODO"""
|
|
153
|
-
length = len(self._items)
|
|
154
|
-
page_index = min(self._show_to + self._diff_index, length)
|
|
155
|
-
self._show_to = max(page_index, self._diff_index)
|
|
156
|
-
self._show_from = self._show_to - self._diff_index
|
|
157
|
-
self._sel_index = self._show_from
|
|
158
|
-
self._re_render = True
|
|
159
|
-
|
|
160
|
-
def _handle_shift_tab(self) -> None:
|
|
161
|
-
"""TODO"""
|
|
162
|
-
page_index = max(self._show_from - self._diff_index, 0)
|
|
163
|
-
self._show_from = min(page_index, self._diff_index)
|
|
164
|
-
self._show_to = self._show_from + self._diff_index
|
|
165
|
-
self._sel_index = self._show_from
|
|
166
|
-
self._re_render = True
|
|
167
|
-
|
|
168
|
-
def _max_rows(self) -> int:
|
|
169
|
-
screen_lines = self.screen.lines - self.ROW_OFFSET
|
|
170
|
-
return min(self.prefs.max_rows, screen_lines)
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.mselect
|
|
7
|
-
@file: mselect.py
|
|
8
|
-
@created: Tue, 4 May 2021
|
|
9
|
-
@author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior"
|
|
10
|
-
@site: https://github.com/yorevs/hspylib
|
|
11
|
-
@license: MIT - Please refer to <https://opensource.org/licenses/MIT>
|
|
12
|
-
|
|
13
|
-
Copyright·(c)·2024,·HSPyLib
|
|
14
|
-
"""
|
|
15
|
-
from clitt.core.tui.mselect.menu_select import MenuSelect
|
|
16
|
-
from hspylib.core.enums.charset import Charset
|
|
17
|
-
from typing import List, Optional, TypeVar
|
|
18
|
-
|
|
19
|
-
T = TypeVar("T")
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def mselect(items: List[T], title: str = "Please select one", output: str = None) -> Optional[T]:
|
|
23
|
-
"""
|
|
24
|
-
Terminal UI menu select input method.
|
|
25
|
-
:param items: the provided items to select from.
|
|
26
|
-
:param title: the title to be displayed before the options.
|
|
27
|
-
:param output: optional output file containing the selected item.
|
|
28
|
-
:return: the selected item.
|
|
29
|
-
"""
|
|
30
|
-
result = MenuSelect(title, items).execute()
|
|
31
|
-
|
|
32
|
-
if result and output:
|
|
33
|
-
with open(output, "w", encoding=Charset.UTF_8.val) as f_out:
|
|
34
|
-
f_out.write(result)
|
|
35
|
-
|
|
36
|
-
return result
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.core.tui.table
|
|
7
|
-
@file: table_enums.py
|
|
8
|
-
@created: Tue, 4 Jul 2023
|
|
9
|
-
@author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior"
|
|
10
|
-
@site: https://github.com/yorevs/hspylib
|
|
11
|
-
@license: MIT - Please refer to <https://opensource.org/licenses/MIT>
|
|
12
|
-
|
|
13
|
-
Copyright·(c)·2024,·HSPyLib
|
|
14
|
-
"""
|
|
15
|
-
from enum import auto
|
|
16
|
-
from hspylib.core.enums.enumeration import Enumeration
|
|
17
|
-
from hspylib.core.tools import text_tools
|
|
18
|
-
from typing import Callable
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class TextAlignment(Enumeration):
|
|
22
|
-
"""Table cell/header text justification helper."""
|
|
23
|
-
|
|
24
|
-
# fmt: off
|
|
25
|
-
LEFT = auto(), text_tools.justified_left
|
|
26
|
-
CENTER = auto(), text_tools.justified_center
|
|
27
|
-
RIGHT = auto(), text_tools.justified_right
|
|
28
|
-
# fmt: on
|
|
29
|
-
|
|
30
|
-
def val(self) -> Callable:
|
|
31
|
-
return self.value[1]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class TextCase(Enumeration):
|
|
35
|
-
"""Table cell/header text case helper."""
|
|
36
|
-
|
|
37
|
-
# fmt: off
|
|
38
|
-
TITLE = auto(), text_tools.titlecase
|
|
39
|
-
SNAKE = auto(), text_tools.snakecase
|
|
40
|
-
CAMEL = auto(), text_tools.camelcase
|
|
41
|
-
KEBAB = auto(), text_tools.kebabcase
|
|
42
|
-
LOWER = auto(), text_tools.lowercase
|
|
43
|
-
UPPER = auto(), text_tools.uppercase
|
|
44
|
-
# fmt: on
|
|
45
|
-
|
|
46
|
-
def val(self) -> Callable:
|
|
47
|
-
return self.value[1]
|