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,14 +0,0 @@
|
|
|
1
|
-
# _*_ coding: utf-8 _*_
|
|
2
|
-
#
|
|
3
|
-
# hspylib-clitt v0.9.120
|
|
4
|
-
#
|
|
5
|
-
# Package: main.build.lib.build.lib.build.lib.clitt.addons.widman
|
|
6
|
-
"""Package initialization."""
|
|
7
|
-
|
|
8
|
-
__all__ = [
|
|
9
|
-
'widget',
|
|
10
|
-
'widget_entry',
|
|
11
|
-
'widgets',
|
|
12
|
-
'widman'
|
|
13
|
-
]
|
|
14
|
-
__version__ = '0.9.120'
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib-Clitt
|
|
6
|
-
@package: clitt.addons.widman
|
|
7
|
-
@file: widget.py
|
|
8
|
-
@created: Fri, 29 Jul 2022
|
|
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
|
-
|
|
16
|
-
from abc import ABC, abstractmethod
|
|
17
|
-
from clitt.core.icons.font_awesome.awesome import Awesome
|
|
18
|
-
from hspylib.modules.application.exit_status import ExitStatus
|
|
19
|
-
from hspylib.modules.application.version import Version
|
|
20
|
-
from textwrap import dedent
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class Widget(ABC):
|
|
24
|
-
"""HsPyLib_Widman base class. All widgets must inherit from this class to properly work."""
|
|
25
|
-
|
|
26
|
-
_USAGE_FMT = dedent(
|
|
27
|
-
"""
|
|
28
|
-
HsPyLib Widget: {} v{}
|
|
29
|
-
|
|
30
|
-
{}
|
|
31
|
-
|
|
32
|
-
{}
|
|
33
|
-
"""
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
def __init__(self, icon: Awesome, name: str, tooltip: str, usage: str, version: Version):
|
|
37
|
-
self._icon = icon
|
|
38
|
-
self._name = name
|
|
39
|
-
self._tooltip = tooltip
|
|
40
|
-
self._usage = usage
|
|
41
|
-
self._version = version
|
|
42
|
-
|
|
43
|
-
@abstractmethod
|
|
44
|
-
def execute(self, *args) -> ExitStatus:
|
|
45
|
-
"""Execute the widget main flow.
|
|
46
|
-
:param args the widget arguments
|
|
47
|
-
"""
|
|
48
|
-
|
|
49
|
-
def cleanup(self) -> None:
|
|
50
|
-
"""Execute the widget cleanup."""
|
|
51
|
-
|
|
52
|
-
def icon(self) -> Awesome:
|
|
53
|
-
"""Return the widget icon."""
|
|
54
|
-
return self._icon
|
|
55
|
-
|
|
56
|
-
def name(self) -> str:
|
|
57
|
-
"""Return the name about the widget."""
|
|
58
|
-
return self._name
|
|
59
|
-
|
|
60
|
-
def tooltip(self) -> str:
|
|
61
|
-
"""Return a tooltip information about the widget."""
|
|
62
|
-
return self._tooltip
|
|
63
|
-
|
|
64
|
-
def version(self) -> str:
|
|
65
|
-
"""Return the version of the widget."""
|
|
66
|
-
return str(self._version)
|
|
67
|
-
|
|
68
|
-
def usage(self) -> str:
|
|
69
|
-
"""Return a usage message about the widget."""
|
|
70
|
-
return self._USAGE_FMT.format(self._name, self._version, self._tooltip, self._usage)
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib-Clitt
|
|
6
|
-
@package: clitt.addons.widman
|
|
7
|
-
@file: widget_entry.py
|
|
8
|
-
@created: Fri, 04 Jun 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 hspylib.core.tools.text_tools import camelcase
|
|
16
|
-
|
|
17
|
-
import os
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class WidgetEntry:
|
|
21
|
-
"""Placeholder object for a HsPyLib::Widman Widget and details about it."""
|
|
22
|
-
|
|
23
|
-
# fmt: off
|
|
24
|
-
MODULE_PREFIX = "widget_"
|
|
25
|
-
CLASS_PREFIX = "Widget"
|
|
26
|
-
# fmt: on
|
|
27
|
-
|
|
28
|
-
def __init__(self, file: str, path: str):
|
|
29
|
-
self._module = os.path.splitext(file)[0]
|
|
30
|
-
self._name = camelcase(self.module.replace(self.MODULE_PREFIX, ""), capitalized=True)
|
|
31
|
-
self._clazz = f"{self.CLASS_PREFIX}{self.name.replace('_', '')}"
|
|
32
|
-
self._path = path
|
|
33
|
-
|
|
34
|
-
def __str__(self):
|
|
35
|
-
return f"{self.name}: {self.module}.{self.clazz} => {self.path}"
|
|
36
|
-
|
|
37
|
-
def __repr__(self):
|
|
38
|
-
return str(self)
|
|
39
|
-
|
|
40
|
-
@property
|
|
41
|
-
def name(self) -> str:
|
|
42
|
-
return self._name
|
|
43
|
-
|
|
44
|
-
@property
|
|
45
|
-
def module(self) -> str:
|
|
46
|
-
return self._module
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def clazz(self) -> str:
|
|
50
|
-
return self._clazz
|
|
51
|
-
|
|
52
|
-
@property
|
|
53
|
-
def path(self) -> str:
|
|
54
|
-
return self._path
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# _*_ coding: utf-8 _*_
|
|
2
|
-
#
|
|
3
|
-
# hspylib-clitt v0.9.120
|
|
4
|
-
#
|
|
5
|
-
# Package: main.build.lib.build.lib.build.lib.clitt.addons.widman.widgets
|
|
6
|
-
"""Package initialization."""
|
|
7
|
-
|
|
8
|
-
__all__ = [
|
|
9
|
-
'widget_free',
|
|
10
|
-
'widget_punch',
|
|
11
|
-
'widget_send_msg',
|
|
12
|
-
'widget_time_calc'
|
|
13
|
-
]
|
|
14
|
-
__version__ = '0.9.120'
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib-Clitt
|
|
6
|
-
@package: clitt.addons.widman.widgets
|
|
7
|
-
@file: widget_free.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.addons.widman.widget import Widget
|
|
16
|
-
from clitt.core.icons.font_awesome.widget_icons import WidgetIcons
|
|
17
|
-
from clitt.core.term.terminal import Terminal
|
|
18
|
-
from concurrent import futures
|
|
19
|
-
from hspylib.core.tools.commons import human_readable_bytes, sysout
|
|
20
|
-
from hspylib.modules.application.exit_status import ExitStatus
|
|
21
|
-
from hspylib.modules.application.version import Version
|
|
22
|
-
from hspylib.modules.cli.keyboard import Keyboard
|
|
23
|
-
from textwrap import dedent
|
|
24
|
-
from time import sleep
|
|
25
|
-
|
|
26
|
-
import re
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class WidgetFree(Widget):
|
|
30
|
-
"""HsPyLib Widget to Report current system memory usage"""
|
|
31
|
-
|
|
32
|
-
# fmt: off
|
|
33
|
-
WIDGET_ICON = WidgetIcons.CHIP
|
|
34
|
-
WIDGET_NAME = "Free"
|
|
35
|
-
VERSION = Version(0, 2, 0)
|
|
36
|
-
TOOLTIP = "Report system memory usage."
|
|
37
|
-
USAGE = "Usage: Free"
|
|
38
|
-
# fmt: on
|
|
39
|
-
|
|
40
|
-
def __init__(self) -> None:
|
|
41
|
-
super().__init__(self.WIDGET_ICON, self.WIDGET_NAME, self.TOOLTIP, self.USAGE, self.VERSION)
|
|
42
|
-
self._is_alive = True
|
|
43
|
-
self._report_interval = 1.5
|
|
44
|
-
self._exit_code = ExitStatus.SUCCESS
|
|
45
|
-
|
|
46
|
-
def execute(self, *args) -> ExitStatus:
|
|
47
|
-
with futures.ThreadPoolExecutor() as executor:
|
|
48
|
-
done = False
|
|
49
|
-
while not done and not Keyboard.kbhit():
|
|
50
|
-
future = executor.submit(self._report_usage)
|
|
51
|
-
done = not future.result()
|
|
52
|
-
if not done:
|
|
53
|
-
sleep(self._report_interval)
|
|
54
|
-
return self._exit_code
|
|
55
|
-
|
|
56
|
-
# pylint: disable=too-many-locals
|
|
57
|
-
@staticmethod
|
|
58
|
-
def _report_usage() -> bool:
|
|
59
|
-
"""Display the memory usage for the cycle."""
|
|
60
|
-
ps, ec1 = Terminal.shell_exec("ps -caxm -orss,comm") # Get process info
|
|
61
|
-
vm, ec2 = Terminal.shell_exec("vm_stat") # Grabbing memory characteristics
|
|
62
|
-
|
|
63
|
-
if ec1 == ExitStatus.SUCCESS and ec2 == ExitStatus.SUCCESS and ps:
|
|
64
|
-
process_lines = ps.split("\n") # Iterate processes
|
|
65
|
-
sep = re.compile(" +")
|
|
66
|
-
rss_total = 0 # kB
|
|
67
|
-
|
|
68
|
-
for row in range(1, len(process_lines)):
|
|
69
|
-
row_text = process_lines[row].strip()
|
|
70
|
-
row_elements = sep.split(row_text)
|
|
71
|
-
if re.match("^[0-9]+$", row_elements[0]):
|
|
72
|
-
rss = float(row_elements[0]) * 1024
|
|
73
|
-
else:
|
|
74
|
-
rss = 0
|
|
75
|
-
rss_total += rss
|
|
76
|
-
|
|
77
|
-
vm_lines = vm.split("\n") # Process vm_stat
|
|
78
|
-
sep = re.compile(": +")
|
|
79
|
-
vm_stats = {}
|
|
80
|
-
|
|
81
|
-
for row in range(1, len(vm_lines) - 2):
|
|
82
|
-
row_text = vm_lines[row].strip()
|
|
83
|
-
row_elements = sep.split(row_text)
|
|
84
|
-
vm_stats[(row_elements[0])] = int(row_elements[1].strip("\\.")) * 4096
|
|
85
|
-
|
|
86
|
-
wired, wu = human_readable_bytes(vm_stats["Pages wired down"])
|
|
87
|
-
active, au = human_readable_bytes(vm_stats["Pages active"])
|
|
88
|
-
inactive, iu = human_readable_bytes(vm_stats["Pages inactive"])
|
|
89
|
-
free, fu = human_readable_bytes(vm_stats["Pages free"])
|
|
90
|
-
real, ru = human_readable_bytes(rss_total) # Total memory
|
|
91
|
-
|
|
92
|
-
sysout(
|
|
93
|
-
dedent(
|
|
94
|
-
f"""
|
|
95
|
-
%HOM%%ED2%%MOD(0)%
|
|
96
|
-
%ORANGE%Reporting system memory usage:%NC%
|
|
97
|
-
{'-' * 30}
|
|
98
|
-
%GREEN% Wired Memory: {wired:6s} {wu:2s}
|
|
99
|
-
%GREEN% Active Memory: {active:6s} {au:2s}
|
|
100
|
-
%GREEN%Inactive Memory: {inactive:6s} {iu:2s}
|
|
101
|
-
%GREEN% Free Memory: {free:6s} {fu:2s}
|
|
102
|
-
%GREEN% Real Memory: {real:6s} {ru:2s}
|
|
103
|
-
|
|
104
|
-
%YELLOW%Press [Enter] to exit ..."""
|
|
105
|
-
)
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
return True
|
|
109
|
-
|
|
110
|
-
return False
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib-Clitt
|
|
6
|
-
@package: clitt.addons.widman.widgets
|
|
7
|
-
@file: widget_punch.py
|
|
8
|
-
@created: Thu, 20 Sep 2022
|
|
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.addons.widman.widget import Widget
|
|
16
|
-
from clitt.addons.widman.widgets.widget_time_calc import WidgetTimeCalc
|
|
17
|
-
from clitt.core.icons.font_awesome.widget_icons import WidgetIcons
|
|
18
|
-
from clitt.core.term.terminal import Terminal
|
|
19
|
-
from hspylib.core.enums.charset import Charset
|
|
20
|
-
from hspylib.core.exception.exceptions import WidgetExecutionError
|
|
21
|
-
from hspylib.core.tools.commons import syserr, sysout
|
|
22
|
-
from hspylib.core.zoned_datetime import now
|
|
23
|
-
from hspylib.modules.application.argparse.argument_parser import HSArgumentParser
|
|
24
|
-
from hspylib.modules.application.exit_status import ExitStatus
|
|
25
|
-
from hspylib.modules.application.version import Version
|
|
26
|
-
from textwrap import dedent
|
|
27
|
-
from typing import List
|
|
28
|
-
|
|
29
|
-
import argparse
|
|
30
|
-
import os
|
|
31
|
-
import re
|
|
32
|
-
import sys
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
class WidgetPunch(Widget):
|
|
36
|
-
"""HsPyLib Widget to Report current system memory usage"""
|
|
37
|
-
|
|
38
|
-
# fmt: off
|
|
39
|
-
WIDGET_ICON = WidgetIcons.PUNCH
|
|
40
|
-
WIDGET_NAME = "Punch"
|
|
41
|
-
VERSION = Version(0, 1, 0)
|
|
42
|
-
TOOLTIP = "!!! PUNCH THE CLOCK !!!"
|
|
43
|
-
USAGE = dedent("""
|
|
44
|
-
"Usage: ${FUNCNAME[0]} [options] <args>"
|
|
45
|
-
|
|
46
|
-
Options: '
|
|
47
|
-
-l : List all registered punches.'
|
|
48
|
-
-e : Edit current punch file.'
|
|
49
|
-
-r : Reset punches for the current week and save the previous one.'
|
|
50
|
-
-w <week> : Report (list) all punches of specified week using the pattern: week-N.punch.'
|
|
51
|
-
|
|
52
|
-
Notes: '
|
|
53
|
-
When no arguments are provided it will !!PUNCH THE CLOCK!!.'
|
|
54
|
-
""")
|
|
55
|
-
|
|
56
|
-
HHS_DIR = os.getenv("HHS_PUNCH_FILE", os.getenv("HOME", "/"))
|
|
57
|
-
|
|
58
|
-
HHS_PUNCH_FILE = os.getenv("HHS_PUNCH_FILE", f"-{HHS_DIR}/.punches")
|
|
59
|
-
|
|
60
|
-
DATE_STAMP = now("%a %d-%m-%Y")
|
|
61
|
-
|
|
62
|
-
TIME_STAMP = now("%H:%M")
|
|
63
|
-
|
|
64
|
-
WEEK_STAMP = int(now("%V"))
|
|
65
|
-
|
|
66
|
-
RE_TODAY_PUNCH_LINE = rf"({DATE_STAMP}).*"
|
|
67
|
-
|
|
68
|
-
RE_PUNCH_LINE = r"^((Mon|Tue|Wed|Thu|Fri|Sat|Sun) )(([0-9]+-?)+) =>.*"
|
|
69
|
-
|
|
70
|
-
MAX_PUNCHES = 7 # 7 week days. Do you work on Saturdays and Sundays ?? :~
|
|
71
|
-
|
|
72
|
-
# fmt: on
|
|
73
|
-
|
|
74
|
-
@staticmethod
|
|
75
|
-
def _daily_total(daily_punches: List[str], decimal: bool = False) -> str:
|
|
76
|
-
"""Calculate the total time from the daily punches.
|
|
77
|
-
:param daily_punches the list of daily punches.
|
|
78
|
-
:param decimal return the total as a decimal number.
|
|
79
|
-
"""
|
|
80
|
-
# Up to 3 pairs of timestamps: morning, afternoon and evening
|
|
81
|
-
if (n := len(daily_punches)) > 0 and n % 2 == 0:
|
|
82
|
-
stamps = []
|
|
83
|
-
stamps += [daily_punches[1], "-", daily_punches[0], "+"] if n // 2 >= 1 else [] # Morning
|
|
84
|
-
stamps += [daily_punches[3], "-", daily_punches[2], "+"] if n // 2 >= 2 else [] # Afternoon
|
|
85
|
-
stamps += [daily_punches[5], "-", daily_punches[4]] if n // 2 >= 3 else [] # Evening
|
|
86
|
-
h, m, _ = WidgetTimeCalc.calc_time(*stamps)
|
|
87
|
-
m = WidgetTimeCalc.to_decimal(m) if decimal else m
|
|
88
|
-
return f"{'%GREEN%' if h >= 8 else '%RED%'}{h:02d}{'.' if decimal else ':'}{m:02d}%NC%"
|
|
89
|
-
|
|
90
|
-
return f"%RED%--{'.' if decimal else ':'}--%NC%"
|
|
91
|
-
|
|
92
|
-
def __init__(self) -> None:
|
|
93
|
-
super().__init__(self.WIDGET_ICON, self.WIDGET_NAME, self.TOOLTIP, self.USAGE, self.VERSION)
|
|
94
|
-
|
|
95
|
-
self._exit_code = ExitStatus.SUCCESS
|
|
96
|
-
self._fn = self._do_the_punch
|
|
97
|
-
self._args = None
|
|
98
|
-
self._today = None
|
|
99
|
-
self._punches = []
|
|
100
|
-
self._total_hour = self._total_min = 0
|
|
101
|
-
self._week_num = self.WEEK_STAMP
|
|
102
|
-
|
|
103
|
-
def execute(self, *args) -> ExitStatus:
|
|
104
|
-
# Create the current week punch file if it does not yet exist.
|
|
105
|
-
if not os.path.exists(self.HHS_PUNCH_FILE):
|
|
106
|
-
with open(self.HHS_PUNCH_FILE, "w", encoding=Charset.UTF_8.val) as f_punch:
|
|
107
|
-
f_punch.write(f"{now('%d-%m-%Y')} => ")
|
|
108
|
-
|
|
109
|
-
ret_val = self._parse_args(*args)
|
|
110
|
-
|
|
111
|
-
if not ret_val:
|
|
112
|
-
return ExitStatus.ABORTED
|
|
113
|
-
|
|
114
|
-
if self._args:
|
|
115
|
-
if "list" == self._args.action:
|
|
116
|
-
self._punches = self._read_punches(self.HHS_PUNCH_FILE)
|
|
117
|
-
self._fn = self._list_punches
|
|
118
|
-
elif "week" == self._args.action:
|
|
119
|
-
punch_dir = os.path.dirname(self.HHS_PUNCH_FILE)
|
|
120
|
-
self._week_num = self._args.week_num
|
|
121
|
-
self._punches = self._read_punches(f"{punch_dir}/week-{self._week_num:02d}.punch")
|
|
122
|
-
self._fn = self._list_punches
|
|
123
|
-
elif "edit" == self._args.action:
|
|
124
|
-
self._fn = self._edit_punches
|
|
125
|
-
elif "reset" == self._args.action:
|
|
126
|
-
self._fn = self._reset_punches
|
|
127
|
-
else:
|
|
128
|
-
self._punches = self._read_punches(self.HHS_PUNCH_FILE)
|
|
129
|
-
|
|
130
|
-
self._fn()
|
|
131
|
-
|
|
132
|
-
return ExitStatus.SUCCESS
|
|
133
|
-
|
|
134
|
-
def _parse_args(self, *args) -> bool:
|
|
135
|
-
"""When arguments are passed from the command line, parse them.
|
|
136
|
-
:param args the widget arguments
|
|
137
|
-
"""
|
|
138
|
-
|
|
139
|
-
if not args:
|
|
140
|
-
return True
|
|
141
|
-
|
|
142
|
-
parser = HSArgumentParser(
|
|
143
|
-
prog="punch",
|
|
144
|
-
prefix_chars="+",
|
|
145
|
-
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
146
|
-
description="PUNCH-THE-CLOCK. This is a helper tool to aid with the timesheet.",
|
|
147
|
-
)
|
|
148
|
-
|
|
149
|
-
subparsers = parser.add_subparsers(title="action", dest="action")
|
|
150
|
-
subparsers.add_parser("list", help="list all registered punches.")
|
|
151
|
-
subparsers.add_parser("edit", help="edit current punch file.")
|
|
152
|
-
subparsers.add_parser("reset", help="reset punches for the current week and save the previous one.")
|
|
153
|
-
|
|
154
|
-
w_parser = subparsers.add_parser("week", help="list all punches of the specified week-num (week-N.punch).")
|
|
155
|
-
w_parser.add_argument("week_num", type=int, default=1, help="the week number")
|
|
156
|
-
|
|
157
|
-
self._args = parser.parse_args(args)
|
|
158
|
-
|
|
159
|
-
return bool(self._args)
|
|
160
|
-
|
|
161
|
-
def _read_punches(self, punch_file: str) -> List[str]:
|
|
162
|
-
"""Read all punches from the punch file.
|
|
163
|
-
:param punch_file the punch file path
|
|
164
|
-
"""
|
|
165
|
-
if not os.path.exists(punch_file):
|
|
166
|
-
syserr(f"Punch file '{punch_file}' not found !")
|
|
167
|
-
raise FileNotFoundError(f"Punch file '{punch_file}' not found !")
|
|
168
|
-
|
|
169
|
-
with open(punch_file, "r", encoding=Charset.UTF_8.val) as f_punch:
|
|
170
|
-
all_punches = list(
|
|
171
|
-
map(self._set_today, filter(lambda l: re.match(self.RE_PUNCH_LINE, l), f_punch.readlines()))
|
|
172
|
-
)
|
|
173
|
-
if len(all_punches) > self.MAX_PUNCHES:
|
|
174
|
-
sysout(f"%RED%Punch file contains more than {self.MAX_PUNCHES} punch lines !%NC%")
|
|
175
|
-
sys.exit(int(str(ExitStatus.FAILED.value)))
|
|
176
|
-
return all_punches
|
|
177
|
-
|
|
178
|
-
def _is_today(self, punch_line: str) -> bool:
|
|
179
|
-
"""Whether the punch line refer to today's date.
|
|
180
|
-
:param punch_line a line read from the punch file (following the punch syntax).
|
|
181
|
-
"""
|
|
182
|
-
return bool(re.match(self.RE_TODAY_PUNCH_LINE, punch_line))
|
|
183
|
-
|
|
184
|
-
def _set_today(self, punch_line: str) -> str:
|
|
185
|
-
"""Set the today's date if the line represents today.
|
|
186
|
-
:param punch_line a line read from the punch file (following the punch syntax).
|
|
187
|
-
"""
|
|
188
|
-
if not self._today and self._is_today(punch_line):
|
|
189
|
-
self._today = punch_line
|
|
190
|
-
return punch_line
|
|
191
|
-
|
|
192
|
-
def _do_the_punch(self) -> None:
|
|
193
|
-
"""Punch the clock."""
|
|
194
|
-
with open(self.HHS_PUNCH_FILE, "w", encoding=Charset.UTF_8.val) as f_punch:
|
|
195
|
-
if not self._today: # Write the first punch of the day
|
|
196
|
-
self._today = f"{self.DATE_STAMP} => {self.TIME_STAMP}"
|
|
197
|
-
self._punches.append(self._today)
|
|
198
|
-
elif self._today.count(":") < 6: # Only allowed 3 groups of 3 pairs of punches
|
|
199
|
-
pat = rf"({self.DATE_STAMP}) => (.*)"
|
|
200
|
-
if mat := re.match(pat, self._today):
|
|
201
|
-
self._today = re.sub(pat, f"{mat.group(1)} => {mat.group(2)} {self.TIME_STAMP} ", self._today)
|
|
202
|
-
else:
|
|
203
|
-
raise WidgetExecutionError("Invalid punch file!")
|
|
204
|
-
self._punches[-1] = self._today
|
|
205
|
-
list(map(f_punch.write, [f"{punch.strip()}\n" for punch in self._punches]))
|
|
206
|
-
sysout(f"{re.sub(self.DATE_STAMP, '%GREEN%Today%NC%', self._today)} ")
|
|
207
|
-
|
|
208
|
-
def _list_punches(self) -> None:
|
|
209
|
-
"""List all punches from the punch file."""
|
|
210
|
-
total = 0, 0
|
|
211
|
-
total_dec = 0, 0
|
|
212
|
-
sysout(f"\n%WHITE%Week-{self._week_num:02d} Punches%NC%")
|
|
213
|
-
sysout("-" * 82)
|
|
214
|
-
for punch_line in self._punches:
|
|
215
|
-
daily_punches = punch_line[17:].strip().split()
|
|
216
|
-
n = len(daily_punches)
|
|
217
|
-
padding = "." * (35 if n == 0 else (36 - n * 6))
|
|
218
|
-
line_color = "%BLUE%" if self._is_today(punch_line) else ""
|
|
219
|
-
sysout(f"{line_color}{punch_line[:17]} {' '.join(daily_punches) + (' ' if n % 2 != 0 else '')}", end="")
|
|
220
|
-
daily_total = self._daily_total(daily_punches)
|
|
221
|
-
daily_total_dec = self._daily_total(daily_punches, decimal=True)
|
|
222
|
-
if n > 0 and n % 2 == 0:
|
|
223
|
-
sysout(f" {padding} : Subtotal = {daily_total} -> {daily_total_dec}%NC%")
|
|
224
|
-
total = WidgetTimeCalc.calc_time(f"{total[0]}:{total[1]}", "+", daily_total[-9:-4])
|
|
225
|
-
total_dec = total[0], WidgetTimeCalc.to_decimal(total[1])
|
|
226
|
-
else:
|
|
227
|
-
sysout(f"{daily_total}%NC%")
|
|
228
|
-
sysout("-" * 82)
|
|
229
|
-
bh, bm, _ = WidgetTimeCalc.calc_time(f"{total[0]}:{total[1]}", "-", "40:00")
|
|
230
|
-
balance = f"{'%BLUE%' if bh >= 0 else '%RED%'}{bh:02d}:{bm:02d}%NC%"
|
|
231
|
-
totals = f"{total[0]:02d}:{total[1]:02d} -> {total_dec[0]:02d}.{total_dec[1]:02d}"
|
|
232
|
-
sysout(f"%WHITE%Total: ({totals}) Balance: {balance}\n")
|
|
233
|
-
|
|
234
|
-
def _edit_punches(self) -> None:
|
|
235
|
-
"""Open the default system editor to edit punches."""
|
|
236
|
-
Terminal.open(self.HHS_PUNCH_FILE)
|
|
237
|
-
|
|
238
|
-
def _reset_punches(self) -> None:
|
|
239
|
-
"""Rename the punch file as a weekly punch file and reset current punch file."""
|
|
240
|
-
punch_dir = os.path.dirname(self.HHS_PUNCH_FILE)
|
|
241
|
-
new_name = f"{punch_dir}/week-{self._week_num:02d}.punch"
|
|
242
|
-
if os.path.exists(new_name):
|
|
243
|
-
sysout(f"%RED%Punch file '{new_name}' already exists!")
|
|
244
|
-
else:
|
|
245
|
-
os.rename(self.HHS_PUNCH_FILE, new_name)
|
|
246
|
-
sysout(f"%YELLOW%Punch file {self.HHS_PUNCH_FILE} renamed to {new_name}")
|