hspylib-clitt 0.9.41__py3-none-any.whl → 0.9.51__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/__classpath__.py +1 -1
- clitt/__init__.py +4 -3
- clitt/__main__.py +8 -41
- clitt/addons/__init__.py +2 -3
- clitt/addons/appman/__init__.py +2 -2
- clitt/addons/appman/appman.py +1 -1
- clitt/addons/appman/templates/__init__.py +2 -2
- clitt/addons/widman/__init__.py +2 -2
- clitt/addons/widman/widgets/__init__.py +2 -2
- clitt/addons/widman/widgets/widget_free.py +2 -1
- clitt/addons/widman/widgets/widget_punch.py +3 -2
- clitt/core/__init__.py +3 -3
- clitt/core/icons/__init__.py +2 -2
- clitt/core/icons/emojis/__init__.py +2 -2
- clitt/core/icons/font_awesome/__init__.py +2 -2
- clitt/core/term/__init__.py +14 -0
- clitt/core/term/commons.py +63 -0
- clitt/core/term/cursor.py +124 -0
- clitt/core/term/screen.py +96 -0
- clitt/core/term/terminal.py +173 -0
- clitt/core/tui/__init__.py +3 -4
- clitt/core/tui/mchoose/__init__.py +2 -2
- clitt/core/tui/mchoose/menu_choose.py +6 -5
- clitt/core/tui/mdashboard/__init__.py +2 -2
- clitt/core/tui/mdashboard/menu_dashboard.py +9 -9
- clitt/core/tui/menu/__init__.py +2 -2
- clitt/core/tui/menu/tui_menu_action.py +1 -3
- clitt/core/tui/menu/tui_menu_item.py +6 -5
- clitt/core/tui/menu/tui_menu_ui.py +5 -7
- clitt/core/tui/menu/tui_menu_view.py +2 -3
- clitt/core/tui/minput/__init__.py +2 -2
- clitt/core/tui/minput/menu_input.py +22 -18
- clitt/core/tui/minput/minput_utils.py +4 -3
- clitt/core/tui/mselect/__init__.py +2 -2
- clitt/core/tui/mselect/menu_select.py +6 -5
- clitt/core/tui/table/__init__.py +2 -2
- clitt/core/tui/table/table_renderer.py +13 -15
- clitt/core/tui/tui_application.py +27 -13
- clitt/core/tui/tui_component.py +28 -21
- clitt/core/tui/tui_preferences.py +3 -0
- clitt/utils/__init__.py +11 -0
- clitt/utils/git_utils.py +67 -0
- clitt/welcome.txt +6 -6
- {hspylib_clitt-0.9.41.dist-info → hspylib_clitt-0.9.51.dist-info}/METADATA +4 -4
- hspylib_clitt-0.9.51.dist-info/RECORD +90 -0
- clitt/addons/setman/__init__.py +0 -13
- clitt/addons/setman/setman.py +0 -148
- clitt/addons/setman/setman_config.py +0 -26
- clitt/addons/setman/setman_enums.py +0 -54
- clitt/core/settings/__init__.py +0 -15
- clitt/core/settings/settings.py +0 -182
- clitt/core/settings/settings_config.py +0 -47
- clitt/core/settings/settings_entry.py +0 -108
- clitt/core/settings/settings_repository.py +0 -103
- clitt/core/settings/settings_service.py +0 -50
- clitt/core/tui/tui_screen.py +0 -222
- hspylib_clitt-0.9.41.dist-info/RECORD +0 -94
- {hspylib_clitt-0.9.41.dist-info → hspylib_clitt-0.9.51.dist-info}/WHEEL +0 -0
- {hspylib_clitt-0.9.41.dist-info → hspylib_clitt-0.9.51.dist-info}/top_level.txt +0 -0
|
@@ -12,15 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
Copyright 2023, HsPyLib team
|
|
14
14
|
"""
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
import csv
|
|
16
|
+
import os
|
|
17
|
+
from typing import Any, Callable, Iterable, List
|
|
18
|
+
|
|
17
19
|
from hspylib.core.preconditions import check_argument
|
|
18
20
|
from hspylib.core.tools.commons import file_is_not_empty
|
|
19
|
-
from hspylib.core.tools.text_tools import elide_text
|
|
20
|
-
from typing import Any, Callable, Iterable, List
|
|
21
|
+
from hspylib.core.tools.text_tools import elide_text, ensure_endswith
|
|
21
22
|
|
|
22
|
-
import
|
|
23
|
-
import
|
|
23
|
+
from clitt.core.term.terminal import Terminal
|
|
24
|
+
from clitt.core.tui.table.table_enums import TextAlignment, TextCase
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class TableRenderer:
|
|
@@ -56,7 +57,7 @@ class TableRenderer:
|
|
|
56
57
|
:param caption: table caption to be displayed.
|
|
57
58
|
"""
|
|
58
59
|
|
|
59
|
-
self.
|
|
60
|
+
self._terminal = Terminal.INSTANCE
|
|
60
61
|
self._headers = headers
|
|
61
62
|
self._columns = range(len(self._headers))
|
|
62
63
|
self._data = data if data else []
|
|
@@ -77,12 +78,8 @@ class TableRenderer:
|
|
|
77
78
|
self.adjust_auto_fit()
|
|
78
79
|
|
|
79
80
|
@property
|
|
80
|
-
def
|
|
81
|
-
return self.
|
|
82
|
-
|
|
83
|
-
@property
|
|
84
|
-
def cursor(self) -> TUIScreen.Cursor:
|
|
85
|
-
return self.screen.cursor
|
|
81
|
+
def terminal(self) -> Terminal:
|
|
82
|
+
return self._terminal
|
|
86
83
|
|
|
87
84
|
@property
|
|
88
85
|
def data(self) -> Iterable:
|
|
@@ -185,7 +182,8 @@ class TableRenderer:
|
|
|
185
182
|
|
|
186
183
|
def export_csv(self, filepath: str, delimiter: chr = ",", has_headers: bool = True) -> None:
|
|
187
184
|
"""Export the table to CSV format."""
|
|
188
|
-
|
|
185
|
+
csv_file = ensure_endswith(filepath, ".csv")
|
|
186
|
+
with open(csv_file, "w", encoding="UTF8") as csv_file:
|
|
189
187
|
writer = csv.writer(csv_file, delimiter=delimiter)
|
|
190
188
|
if has_headers:
|
|
191
189
|
writer.writerow(self._headers)
|
|
@@ -193,7 +191,7 @@ class TableRenderer:
|
|
|
193
191
|
|
|
194
192
|
def _display_data(self, data: Any) -> None:
|
|
195
193
|
"""Print out data into the screen."""
|
|
196
|
-
self.cursor.writeln(data)
|
|
194
|
+
self.terminal.cursor.writeln(data)
|
|
197
195
|
|
|
198
196
|
def _format_header_row(self) -> str:
|
|
199
197
|
"""Format the table header using the defined preferences."""
|
|
@@ -12,12 +12,17 @@
|
|
|
12
12
|
|
|
13
13
|
Copyright 2023, HsPyLib team
|
|
14
14
|
"""
|
|
15
|
+
import os
|
|
16
|
+
import sys
|
|
15
17
|
|
|
16
18
|
from hspylib.core.metaclass.singleton import AbstractSingleton
|
|
17
19
|
from hspylib.modules.application.application import Application
|
|
18
20
|
from hspylib.modules.application.exit_status import ExitStatus
|
|
19
21
|
from hspylib.modules.application.version import Version
|
|
20
|
-
|
|
22
|
+
|
|
23
|
+
from clitt.core.term.cursor import Cursor
|
|
24
|
+
from clitt.core.term.screen import Screen
|
|
25
|
+
from clitt.core.term.terminal import Terminal
|
|
21
26
|
|
|
22
27
|
|
|
23
28
|
class TUIApplication(Application, metaclass=AbstractSingleton):
|
|
@@ -25,16 +30,29 @@ class TUIApplication(Application, metaclass=AbstractSingleton):
|
|
|
25
30
|
|
|
26
31
|
def __init__(
|
|
27
32
|
self,
|
|
28
|
-
name: str,
|
|
29
|
-
version: Version,
|
|
33
|
+
name: str | None,
|
|
34
|
+
version: Version = Version.initial(),
|
|
30
35
|
description: str = None,
|
|
31
36
|
usage: str = None,
|
|
32
37
|
epilog: str = None,
|
|
33
38
|
resource_dir: str = None,
|
|
34
|
-
log_dir: str = None
|
|
35
|
-
|
|
39
|
+
log_dir: str = None):
|
|
40
|
+
|
|
36
41
|
super().__init__(name, version, description, usage, epilog, resource_dir, log_dir)
|
|
37
|
-
self.
|
|
42
|
+
self._terminal = Terminal.INSTANCE
|
|
43
|
+
self._app_name = os.path.basename(sys.argv[0]) if name is None else name
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def terminal(self) -> Terminal():
|
|
47
|
+
return self._terminal
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def screen(self) -> Screen():
|
|
51
|
+
return self.terminal.screen
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def cursor(self) -> Cursor:
|
|
55
|
+
return self.terminal.cursor
|
|
38
56
|
|
|
39
57
|
def _setup_arguments(self) -> None:
|
|
40
58
|
pass
|
|
@@ -43,10 +61,6 @@ class TUIApplication(Application, metaclass=AbstractSingleton):
|
|
|
43
61
|
pass
|
|
44
62
|
|
|
45
63
|
def _cleanup(self) -> None:
|
|
46
|
-
if self.
|
|
47
|
-
self.
|
|
48
|
-
|
|
49
|
-
def _alternate_screen(self):
|
|
50
|
-
"""Toggle switch to the alternate/main screen."""
|
|
51
|
-
self._alt_screen = not self._alt_screen
|
|
52
|
-
alternate_screen(self._alt_screen)
|
|
64
|
+
if self.screen.alternate and self._exit_code == ExitStatus.SUCCESS:
|
|
65
|
+
self.screen.alternate = not self.screen.alternate
|
|
66
|
+
self.terminal.restore()
|
clitt/core/tui/tui_component.py
CHANGED
|
@@ -13,13 +13,16 @@
|
|
|
13
13
|
Copyright 2023, HsPyLib team
|
|
14
14
|
"""
|
|
15
15
|
from abc import ABC, abstractmethod
|
|
16
|
-
from
|
|
17
|
-
|
|
18
|
-
from clitt.core.tui.tui_screen import TUIScreen
|
|
16
|
+
from typing import Any, List, Optional, TypeVar
|
|
17
|
+
|
|
19
18
|
from hspylib.core.tools.text_tools import elide_text
|
|
20
19
|
from hspylib.modules.cli.keyboard import Keyboard
|
|
21
|
-
|
|
22
|
-
from
|
|
20
|
+
|
|
21
|
+
from clitt.core.icons.font_awesome.awesome import Awesome
|
|
22
|
+
from clitt.core.term.terminal import Terminal
|
|
23
|
+
from clitt.core.term.cursor import Cursor
|
|
24
|
+
from clitt.core.term.screen import Screen
|
|
25
|
+
from clitt.core.tui.tui_preferences import TUIPreferences
|
|
23
26
|
|
|
24
27
|
T = TypeVar("T", bound=Any)
|
|
25
28
|
|
|
@@ -31,7 +34,19 @@ class TUIComponent(ABC):
|
|
|
31
34
|
self._re_render = True
|
|
32
35
|
self._done = False
|
|
33
36
|
self._title = title
|
|
34
|
-
self.
|
|
37
|
+
self._terminal = Terminal.INSTANCE
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def terminal(self) -> Terminal:
|
|
41
|
+
return self._terminal
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def screen(self) -> Screen:
|
|
45
|
+
return self.terminal.screen
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def cursor(self) -> Cursor:
|
|
49
|
+
return self.terminal.screen.cursor
|
|
35
50
|
|
|
36
51
|
@property
|
|
37
52
|
def title(self) -> str:
|
|
@@ -39,30 +54,22 @@ class TUIComponent(ABC):
|
|
|
39
54
|
|
|
40
55
|
@property
|
|
41
56
|
def rows(self) -> int:
|
|
42
|
-
return self.
|
|
57
|
+
return self.screen.lines
|
|
43
58
|
|
|
44
59
|
@property
|
|
45
60
|
def columns(self) -> int:
|
|
46
|
-
return self.
|
|
61
|
+
return self.screen.columns
|
|
47
62
|
|
|
48
63
|
@property
|
|
49
64
|
def prefs(self) -> TUIPreferences:
|
|
50
65
|
return self.screen.preferences
|
|
51
66
|
|
|
52
|
-
@property
|
|
53
|
-
def screen(self) -> TUIScreen:
|
|
54
|
-
return self._screen
|
|
55
|
-
|
|
56
|
-
@property
|
|
57
|
-
def cursor(self) -> TUIScreen.Cursor:
|
|
58
|
-
return self._screen.cursor
|
|
59
|
-
|
|
60
67
|
def _prepare_render(self, auto_wrap: bool = False, show_cursor: bool = False) -> None:
|
|
61
68
|
"""Prepare the screen for renderization."""
|
|
62
69
|
|
|
63
|
-
self.
|
|
64
|
-
set_auto_wrap(auto_wrap)
|
|
65
|
-
set_show_cursor(show_cursor)
|
|
70
|
+
self.screen.add_watcher(self.invalidate)
|
|
71
|
+
Terminal.set_auto_wrap(auto_wrap)
|
|
72
|
+
Terminal.set_show_cursor(show_cursor)
|
|
66
73
|
self.screen.clear()
|
|
67
74
|
self.cursor.save()
|
|
68
75
|
|
|
@@ -118,11 +125,11 @@ class TUIComponent(ABC):
|
|
|
118
125
|
|
|
119
126
|
def write(self, obj: Any) -> None:
|
|
120
127
|
"""Write the string representation of the object to the screen."""
|
|
121
|
-
self.
|
|
128
|
+
self.terminal.echo(obj, end='')
|
|
122
129
|
|
|
123
130
|
def writeln(self, obj: Any) -> None:
|
|
124
131
|
"""Write the string representation of the object to the screen, appending a new line."""
|
|
125
|
-
self.
|
|
132
|
+
self.terminal.echo(obj)
|
|
126
133
|
|
|
127
134
|
def invalidate(self) -> None:
|
|
128
135
|
"""Invalidate current TUI renderization."""
|
clitt/utils/__init__.py
ADDED
clitt/utils/git_utils.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
@project: HsPyLib
|
|
6
|
+
@package: clitt.utils
|
|
7
|
+
@file: git_utils.py
|
|
8
|
+
@created: Nov 14, 2019
|
|
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 2023, HsPyLib team
|
|
14
|
+
"""
|
|
15
|
+
from hspylib.modules.application.exit_status import ExitStatus
|
|
16
|
+
from typing import Tuple
|
|
17
|
+
|
|
18
|
+
from clitt.core.terminal import Terminal
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class GitTools:
|
|
22
|
+
"""TODO"""
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def top_level_dir() -> Tuple[str, ExitStatus]:
|
|
26
|
+
"""TODO"""
|
|
27
|
+
return Terminal.shell_exec("git rev-parse --show-toplevel")
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def current_branch() -> Tuple[str, ExitStatus]:
|
|
31
|
+
"""TODO"""
|
|
32
|
+
return Terminal.shell_exec("git symbolic-ref --short HEAD")
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def changelog(from_tag: str, to_tag: str) -> Tuple[str, ExitStatus]:
|
|
36
|
+
"""TODO"""
|
|
37
|
+
return Terminal.shell_exec(f"git log --oneline --pretty='format:%h %ad %s' --date=short {from_tag}^..{to_tag}^")
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def unreleased() -> Tuple[str, ExitStatus]:
|
|
41
|
+
"""TODO"""
|
|
42
|
+
latest_tag = Terminal.shell_exec("git describe --tags --abbrev=0 HEAD^")
|
|
43
|
+
return Terminal.shell_exec(f"git log --oneline --pretty='format:%h %ad %s' --date=short '{latest_tag}'..HEAD")
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def release_date(tag_name: str) -> Tuple[str, ExitStatus]:
|
|
47
|
+
"""TODO"""
|
|
48
|
+
return Terminal.shell_exec(f"git log -1 --pretty='format:%ad' --date=short {tag_name}")
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def tag_list() -> Tuple[str, ExitStatus]:
|
|
52
|
+
"""TODO"""
|
|
53
|
+
return Terminal.shell_exec("git log --tags --simplify-by-decoration --pretty='format:%ci %d'")
|
|
54
|
+
|
|
55
|
+
@staticmethod
|
|
56
|
+
def create_tag(version: str, commit_id: str = "HEAD", description: str = None) -> Tuple[str, ExitStatus]:
|
|
57
|
+
"""TODO"""
|
|
58
|
+
return Terminal.shell_exec(f"git tag -a v{version} {commit_id} -m '{description or version}'")
|
|
59
|
+
|
|
60
|
+
@staticmethod
|
|
61
|
+
def search_logs(filter_by: str = ".*") -> Tuple[str, ExitStatus]:
|
|
62
|
+
"""TODO"""
|
|
63
|
+
return Terminal.shell_exec(f"git log --grep='{filter_by}' --pretty=format:'%h %ad %s' --date=short")
|
|
64
|
+
|
|
65
|
+
@staticmethod
|
|
66
|
+
def show_file(filename: str, commit_id: str = "HEAD") -> Tuple[str, ExitStatus]:
|
|
67
|
+
return Terminal.shell_exec(f"git show {commit_id}:{filename}")
|
clitt/welcome.txt
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
| |
|
|
5
|
-
|
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
____ _ _ _ _
|
|
3
|
+
/ ___| (_) |_| |_
|
|
4
|
+
| | | | | __| __|
|
|
5
|
+
| |___| | | |_| |_
|
|
6
|
+
\____|_|_|\__|\__|
|
|
7
|
+
|
|
8
8
|
|
|
9
9
|
HsPyLib CLI Terminal Tools v{} - Create professional CLI applications.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hspylib-clitt
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.51
|
|
4
4
|
Summary: HsPyLib - CLI Terminal Tools
|
|
5
5
|
Home-page: https://github.com/yorevs/hspylib
|
|
6
6
|
Author: Hugo Saporetti Junior
|
|
@@ -8,7 +8,7 @@ Author-email: yorevs@hotmail.com
|
|
|
8
8
|
License: MIT
|
|
9
9
|
Project-URL: GitHub, https://github.com/yorevs/hspylib
|
|
10
10
|
Project-URL: PyPi, https://pypi.org/project/hspylib-clitt/
|
|
11
|
-
Keywords:
|
|
11
|
+
Keywords: cli,clitt,terminal,tui,manager,application,widgets
|
|
12
12
|
Platform: Darwin
|
|
13
13
|
Platform: Linux
|
|
14
14
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -31,8 +31,8 @@ Requires-Dist: hspylib
|
|
|
31
31
|
## Create professional CLI applications
|
|
32
32
|
|
|
33
33
|
[](LICENSE.md)
|
|
34
|
-
[](https://pypi.org/project/hspylib-
|
|
34
|
+
[](CHANGELOG.md#unreleased)
|
|
35
|
+
[](https://pypi.org/project/hspylib-clitt)
|
|
36
36
|
[](https://github.com/yorevs/hspylib)
|
|
37
37
|
[](https://gitter.im/hspylib/community)
|
|
38
38
|
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=J5CDEFLF6M3H4)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
clitt/.version,sha256=4YMwh1CMt_3TOiIMAQBqo20qGAySIKG-YY6hDVss4WM,7
|
|
2
|
+
clitt/__classpath__.py,sha256=kYZgQkSaFnCHBKz_NslH61gm2jUygluqiILe29MTVSo,784
|
|
3
|
+
clitt/__init__.py,sha256=2rWLV5hBTj-AEejAX_QefhdU3PdmtwwjK3I1qJIz98U,176
|
|
4
|
+
clitt/__main__.py,sha256=GZV_8hSXmN7HCGVtwduLh08vYgj2Moqz6O0Orj-KjNc,5328
|
|
5
|
+
clitt/welcome.txt,sha256=z72ySJw-1VQHvWmd8pZ95P6t4zEkIWGbqTRT83P2hJw,169
|
|
6
|
+
clitt/addons/__init__.py,sha256=1jNz7bz7f3UiDaOgAs5dHb93GQcBUqM7jPtQZbKRA88,173
|
|
7
|
+
clitt/addons/appman/__init__.py,sha256=1wVp2UymxDOR7xSBeQJU-RI-oaboEJl3LXYOsJU6-i8,202
|
|
8
|
+
clitt/addons/appman/appman.py,sha256=lZGOU0A-2SDXj6DG9QfNE3whPb_qFCqbs7m7Vve2meY,13146
|
|
9
|
+
clitt/addons/appman/appman_enums.py,sha256=vBCmCSGYfVY1VwyEAw9UzbcvNkZSGvHtlUhBBMgcDz0,872
|
|
10
|
+
clitt/addons/appman/templates/__init__.py,sha256=o6xzRDFqQPhBQtAPsT94_kFsYd_0zTqDMGQa2CjPizQ,169
|
|
11
|
+
clitt/addons/appman/templates/build.gradle.tpl,sha256=VQKs4r41xPr7P14PtQPt3alYCmNuXaGraaXbKB_FKkM,1817
|
|
12
|
+
clitt/addons/appman/templates/classpath.py.tpl,sha256=R60uLvVxeJ7nJCXCvav_9LAnDe5VOfJqWO-T1QAlwAc,397
|
|
13
|
+
clitt/addons/appman/templates/dependencies.hspd.tpl,sha256=bbVNU6XBm5QT28lvH7Bp_4nlXvoD-LwX5kGQ-CPhOEA,764
|
|
14
|
+
clitt/addons/appman/templates/gitignore.tpl,sha256=OLb8eoac2nnG1lvZL2l7J_3mc94i6xTuIfCV-J8aFSM,903
|
|
15
|
+
clitt/addons/appman/templates/main.py.tpl,sha256=bHvc8yrqn-8Ksm0vaBxufGaWwvsEd27DX8YPYULLDro,1506
|
|
16
|
+
clitt/addons/appman/templates/main_qt.py.tpl,sha256=1nlBCVjZZmIackSpBQwgWm6ygYQGpjodI9oHuLucw58,1043
|
|
17
|
+
clitt/addons/appman/templates/main_qt_view.py.tpl,sha256=mGGsuXY88MPugt9fvZdCK_yiAxedTeikrcSIWeHh8Jc,626
|
|
18
|
+
clitt/addons/appman/templates/main_qt_view.ui.tpl,sha256=JbEz9xU_50_Fd8FCKC33WPCz4De0egg1eW2xvP8wzJI,2780
|
|
19
|
+
clitt/addons/appman/templates/run.sh.tpl,sha256=2xpuHjZP9-7j14dAA2CqPm4G2xtnuenf-RBe3LdC2rI,150
|
|
20
|
+
clitt/addons/appman/templates/test_main.py.tpl,sha256=x_xuKy2O2b1bs6tuzOUqF5shnx-2-EfFRc7sBV4Fndc,1239
|
|
21
|
+
clitt/addons/appman/templates/usage.txt.tpl,sha256=R0e48HCeD7PDbWnX6HGIjz6gr_hBdp-zK6V42U1Aexw,217
|
|
22
|
+
clitt/addons/appman/templates/widget.py.tpl,sha256=JmlO5rh2ETCF5ldiB9MStfjB4oB4JLI8UUnNP5SAAcM,1668
|
|
23
|
+
clitt/addons/widman/__init__.py,sha256=_V0puMkk-IK8CAME9qmC_XHPTCalXT8Mdei9MWYCSPU,213
|
|
24
|
+
clitt/addons/widman/widget.py,sha256=mIEB3Fs4ypaUMhh85meg2vMhKJVjW8Tyxkp_XqHIHtA,1920
|
|
25
|
+
clitt/addons/widman/widget_entry.py,sha256=8Shj4_esh6KN69usTrCcUsfGVas81Xz0QabsY_zV9o0,1350
|
|
26
|
+
clitt/addons/widman/widman.py,sha256=kfv3CcDSjUZglurPXa4Bv1jYELtEkbixOjpVL8yRf3M,5260
|
|
27
|
+
clitt/addons/widman/widgets/__init__.py,sha256=iIDviz7Fj1Vcn8DN01pJUKk2R9-6Hy-FYQSTWIcija8,244
|
|
28
|
+
clitt/addons/widman/widgets/widget_free.py,sha256=C5RNyItm_VVM8UlpzeC5mER6KTykJ0eIS3Q5H2bgSKw,3989
|
|
29
|
+
clitt/addons/widman/widgets/widget_punch.py,sha256=dUb3w2MEvcwilxZZYWQZirut0-thQZMwAzSa4904vqg,10522
|
|
30
|
+
clitt/addons/widman/widgets/widget_send_msg.py,sha256=MMBOGTBc6c3jgLgZBzbQIiQsSs5jl-8ohqy7evMSNQU,11056
|
|
31
|
+
clitt/addons/widman/widgets/widget_time_calc.py,sha256=JQOHRf5OFDL73Y-GJEWtdN5_s2vKR-9mX0yoisxNQRg,5100
|
|
32
|
+
clitt/core/__init__.py,sha256=XTVUnQAZPO8PDETBR4wIPBpAaKGkpa5fv2HsNG_1rCw,178
|
|
33
|
+
clitt/core/icons/__init__.py,sha256=0BUENJrRCONnLxLjbWXow6KYIkZ6eGiQqzSjOSu7iQ0,183
|
|
34
|
+
clitt/core/icons/emojis/__init__.py,sha256=OsMCRsGmeH50ZOdBdm9bBQqsH1Of_Df6GJJks3g0y3U,190
|
|
35
|
+
clitt/core/icons/emojis/emojis.py,sha256=LbwpjJonRlNVPa6eMEDTreQz1fmFfFK4dOk6X-4XHrI,1109
|
|
36
|
+
clitt/core/icons/emojis/face_smiling.py,sha256=qho6t7W3za6-H9bW51_0RoYKah_f0_DCJ0EiCiwvQwI,1269
|
|
37
|
+
clitt/core/icons/font_awesome/__init__.py,sha256=MW9eM_62rfdz8zFVErzMxciYmO2sfKeLcYTbGC1lo-g,288
|
|
38
|
+
clitt/core/icons/font_awesome/app_icons.py,sha256=cMPlXVWOn5YnLmlk20nwhFgA16Ug2jFiHZPYlwwH724,1662
|
|
39
|
+
clitt/core/icons/font_awesome/awesome.py,sha256=oEOi0DWj0yvJbmg18fXE5hgSrMmCckTYC0cbgw1cyQQ,1831
|
|
40
|
+
clitt/core/icons/font_awesome/control_icons.py,sha256=OuAnvXRIusxDRVnPHxltTn4V6tF_uc2gfoqoQWB7Bks,1075
|
|
41
|
+
clitt/core/icons/font_awesome/dashboard_icons.py,sha256=MGXLJ-I_xXalOaLeWHkaZe5ZIqdycNLg4S-L7abBHEU,3085
|
|
42
|
+
clitt/core/icons/font_awesome/form_icons.py,sha256=mDF_0nFJ9VYO2ZoXWSTETm7qEd03dcIgeCUpFnH0sLI,2314
|
|
43
|
+
clitt/core/icons/font_awesome/nav_icons.py,sha256=A3GqJuwD-RKybY67THimI1oqcNlDSEaA_Hdy8LSzfqo,1105
|
|
44
|
+
clitt/core/icons/font_awesome/widget_icons.py,sha256=Oho4jPezyMSw-tKWSjpdK3dv-FK2GC_62liNeThhhAs,1024
|
|
45
|
+
clitt/core/term/__init__.py,sha256=_ez8HlAYFteb6eA8rwSZHPEGWaRo9xo0pAPnFy_PlhQ,205
|
|
46
|
+
clitt/core/term/commons.py,sha256=qsE575i6VTehljHbezgQKJAu4hcoVz-D1kDhbes_elE,2055
|
|
47
|
+
clitt/core/term/cursor.py,sha256=2sWYzEdZmOn9j6ded21Jb_2NSYRA-eEmaQPk6ADL-nU,4822
|
|
48
|
+
clitt/core/term/screen.py,sha256=9su9S6kxSlgMt9VRCJh1tYFBADgs9lSZZ9aQig6ASYg,3090
|
|
49
|
+
clitt/core/term/terminal.py,sha256=0ljL00Oj4kMJshPBlemSMtedGv-grY-gjPRlnn49SO0,6563
|
|
50
|
+
clitt/core/tui/__init__.py,sha256=tKCff1jjIxcA58ZQfG92Iv3IEpIFEn3e4Q4kFwKcW5Y,294
|
|
51
|
+
clitt/core/tui/tui_application.py,sha256=cMihfVoampEAdWqG-J8SA9uVeannJIDRomGK9g9dwYQ,1942
|
|
52
|
+
clitt/core/tui/tui_component.py,sha256=5xMzTvCmWodTng1URvL6fybcxmPracWz8b76vvcng_M,4770
|
|
53
|
+
clitt/core/tui/tui_preferences.py,sha256=N1HAbdz7q556iegqgwDhxQ2s6QNOoKTnIBsFCYWBwpQ,4803
|
|
54
|
+
clitt/core/tui/mchoose/__init__.py,sha256=hK_fes0_MxfRoPwOQTZVOzN_BRRWuenWjx9GlWPO9e8,189
|
|
55
|
+
clitt/core/tui/mchoose/mchoose.py,sha256=ZW7mr7WCP2Lc545PBy2-QRaUt6BNYP5cAwczooU86eU,1180
|
|
56
|
+
clitt/core/tui/mchoose/menu_choose.py,sha256=C2si3HuytBqMwKibEUT6AB7VqNSCadbC8SqMcjwe5Ms,7022
|
|
57
|
+
clitt/core/tui/mdashboard/__init__.py,sha256=Vav4r8hPZjqzBPcbrcrAUQioHIXk_EhDrYhZo1XI0JU,243
|
|
58
|
+
clitt/core/tui/mdashboard/dashboard_builder.py,sha256=wWcT1UyQnOrvalV920XtmBUg5lRVbhA8hMrmxRcLrtY,1658
|
|
59
|
+
clitt/core/tui/mdashboard/dashboard_item.py,sha256=4MK6bxROWo1ZK9FlMoSm38z0qe5HoxqH0W5tt3iUT5M,886
|
|
60
|
+
clitt/core/tui/mdashboard/mdashboard.py,sha256=juNPFzmoKQRJa2CZFxVZAFr2QXFna3cvsoYlFNaQjis,890
|
|
61
|
+
clitt/core/tui/mdashboard/menu_dashboard.py,sha256=uUlWPr66h3sz-Qh8WiKcs4V9VXJdD6EzIheOwN0CZv8,5496
|
|
62
|
+
clitt/core/tui/menu/__init__.py,sha256=WZuoTfSnyeVmp2u-XHL2_UJS7HPOcllYkorUbV4TS0s,272
|
|
63
|
+
clitt/core/tui/menu/tui_menu.py,sha256=nAux3qJ6_kyvV6Z2IbIG6dS62zFfTo5qA4rB8cXAIYk,3593
|
|
64
|
+
clitt/core/tui/menu/tui_menu_action.py,sha256=AH7G3RHVRqcAUD0wHd_t6-vEOZoB0Xo5wtfS8ZBcDIM,1539
|
|
65
|
+
clitt/core/tui/menu/tui_menu_factory.py,sha256=rL33KX5yD2ppvVRAEFIAme5ka7GrBQecVr63aUf2hf0,4459
|
|
66
|
+
clitt/core/tui/menu/tui_menu_item.py,sha256=EEaV09ZsSvspZAXrqzHHnhQdyyOVfmotC0m2mjyaRbg,7490
|
|
67
|
+
clitt/core/tui/menu/tui_menu_ui.py,sha256=R_Ov_NpCe9lGmzp2MqH0igD6jxIMN5uPqSrjAuDLvwo,3332
|
|
68
|
+
clitt/core/tui/menu/tui_menu_view.py,sha256=4HrwHcKuAyCx7npIy1ds5Jmvg8yIxndwq65wPUevn50,1926
|
|
69
|
+
clitt/core/tui/minput/__init__.py,sha256=h87WnxOylZUYJ15_dtJibYfI3DUjPpKWkIgwQtBq1DM,318
|
|
70
|
+
clitt/core/tui/minput/access_type.py,sha256=Dss6okfXHCoUI3_OOu2nKsgpy2NeStIwhdDvTR2z-2w,636
|
|
71
|
+
clitt/core/tui/minput/field_builder.py,sha256=5te6nDYHCa9VmzGK0b1lXRCc7n4GbMIVIR2InLdLzXg,4414
|
|
72
|
+
clitt/core/tui/minput/form_builder.py,sha256=CwUpswLD9rTCs3PXaOpu0bFKavHsbUkgs4OnQgbS-RQ,2865
|
|
73
|
+
clitt/core/tui/minput/form_field.py,sha256=5p-IT_2RgzkU4RfyXihrNdD9_yV4X5FqNgIckDE9zEQ,5766
|
|
74
|
+
clitt/core/tui/minput/input_type.py,sha256=O6-jk_QSjjRGeHsGVzIDZSCLg739f2xtnVV_ElcHYpA,722
|
|
75
|
+
clitt/core/tui/minput/input_validator.py,sha256=XjK9O435OIvuyAHAY7XJt_ELvJ-sJsWIO-jv6hVt2-c,3360
|
|
76
|
+
clitt/core/tui/minput/menu_input.py,sha256=reQsGdjiTRIPcwXUlG1A0pNstJXLjQxKtIW8fHdfyT8,12818
|
|
77
|
+
clitt/core/tui/minput/minput.py,sha256=20Vz-SRVaNuqYJrG6kdkdE4bVy_YNjXEcYaFEnRCqNQ,1532
|
|
78
|
+
clitt/core/tui/minput/minput_utils.py,sha256=2jjKFwO376OmyS5CWPGjT3QXdaN02Pq5eqfmRvWkKSw,5266
|
|
79
|
+
clitt/core/tui/mselect/__init__.py,sha256=9TGnHHXC42FLyNLE5xOkq1wHR7S02M5D__PgyDcSDJk,189
|
|
80
|
+
clitt/core/tui/mselect/menu_select.py,sha256=zb2GGcRVldzsdY54_rQZuYdqZ3CrqhLdjYNdpC4ZRWg,6184
|
|
81
|
+
clitt/core/tui/mselect/mselect.py,sha256=3Q4X2XMqhXCicO5XhDXsldn9m-1bWOQ9ez1MLMj8fps,1040
|
|
82
|
+
clitt/core/tui/table/__init__.py,sha256=Z-3ErauMjZt_7aneg0Gp28O5Z9VXgSLXcDAXyqcKOxQ,194
|
|
83
|
+
clitt/core/tui/table/table_enums.py,sha256=gbA2e7kgpjLjL8oxbIGalcX-cyaXPfdXy01wzivqpWc,1183
|
|
84
|
+
clitt/core/tui/table/table_renderer.py,sha256=cFFm1peA3VoThI845qPqhz-62Oa3Ll4m3hLmYL4jHjA,9622
|
|
85
|
+
clitt/utils/__init__.py,sha256=Bda6YsNvmIiAS7ZPGzhNVT1SVDWaJxG32XoJF-T86dM,162
|
|
86
|
+
clitt/utils/git_utils.py,sha256=avAsBjaG3jcBNsBvu5dcH99RERkZSY6cQXmJLYAOV8c,2386
|
|
87
|
+
hspylib_clitt-0.9.51.dist-info/METADATA,sha256=tP9B_f6UnL-cOSPOgn_M-2DKTXmS6K8LJ8pJCJudL-o,1733
|
|
88
|
+
hspylib_clitt-0.9.51.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
|
89
|
+
hspylib_clitt-0.9.51.dist-info/top_level.txt,sha256=vrnpkFU7dZ-vH7x5xdcY1vJSuboTqPBUcc3jD6SJkAo,6
|
|
90
|
+
hspylib_clitt-0.9.51.dist-info/RECORD,,
|
clitt/addons/setman/__init__.py
DELETED
clitt/addons/setman/setman.py
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib
|
|
6
|
-
@package: clitt.addons.setman
|
|
7
|
-
@file: setman.py
|
|
8
|
-
@created: Fri, 29 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 2023, HsPyLib team
|
|
14
|
-
"""
|
|
15
|
-
import atexit
|
|
16
|
-
import logging as log
|
|
17
|
-
import os
|
|
18
|
-
from typing import Any
|
|
19
|
-
|
|
20
|
-
from hspylib.core.enums.charset import Charset
|
|
21
|
-
from hspylib.core.metaclass.singleton import Singleton
|
|
22
|
-
from hspylib.core.preconditions import check_state
|
|
23
|
-
from hspylib.core.tools.commons import file_is_not_empty, syserr, sysout
|
|
24
|
-
from hspylib.modules.application.application import Application
|
|
25
|
-
from hspylib.modules.cli.keyboard import Keyboard
|
|
26
|
-
|
|
27
|
-
from clitt.addons.setman.setman_config import SetmanConfig
|
|
28
|
-
from clitt.addons.setman.setman_enums import SetmanOps, SettingsType
|
|
29
|
-
from clitt.core.settings.settings import Settings
|
|
30
|
-
from clitt.core.tui.table.table_enums import TextAlignment
|
|
31
|
-
from clitt.core.tui.table.table_renderer import TableRenderer
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class SetMan(metaclass=Singleton):
|
|
35
|
-
"""HsPyLib application that helps managing system settings."""
|
|
36
|
-
|
|
37
|
-
RESOURCE_DIR = os.environ.get("HHS_DIR", os.environ.get("HOME", "~/"))
|
|
38
|
-
|
|
39
|
-
SETMAN_CONFIG_FILE = f"setman.properties"
|
|
40
|
-
|
|
41
|
-
SETMAN_DB_FILE = f"{RESOURCE_DIR}/.setman-db"
|
|
42
|
-
|
|
43
|
-
def __init__(self, parent_app: Application) -> None:
|
|
44
|
-
self._parent_app = parent_app
|
|
45
|
-
cfg_file = f"{self.RESOURCE_DIR}/{self.SETMAN_CONFIG_FILE}"
|
|
46
|
-
if not file_is_not_empty(cfg_file):
|
|
47
|
-
self._setup(cfg_file)
|
|
48
|
-
self._configs = SetmanConfig(self.RESOURCE_DIR, self.SETMAN_CONFIG_FILE)
|
|
49
|
-
self._settings = Settings(self.configs)
|
|
50
|
-
|
|
51
|
-
def __str__(self):
|
|
52
|
-
data = set(self.settings.list())
|
|
53
|
-
vault_str = ""
|
|
54
|
-
for entry in data:
|
|
55
|
-
vault_str += entry.key
|
|
56
|
-
return vault_str
|
|
57
|
-
|
|
58
|
-
def __repr__(self):
|
|
59
|
-
return str(self)
|
|
60
|
-
|
|
61
|
-
@property
|
|
62
|
-
def configs(self) -> SetmanConfig:
|
|
63
|
-
return self._configs
|
|
64
|
-
|
|
65
|
-
@property
|
|
66
|
-
def settings(self) -> Settings:
|
|
67
|
-
return self._settings
|
|
68
|
-
|
|
69
|
-
def execute(
|
|
70
|
-
self,
|
|
71
|
-
operation: SetmanOps,
|
|
72
|
-
name: str | None,
|
|
73
|
-
value: Any | None,
|
|
74
|
-
stype: SettingsType = None,
|
|
75
|
-
simple_fmt: bool = False,
|
|
76
|
-
) -> None:
|
|
77
|
-
"""Execute the specified operation."""
|
|
78
|
-
log.debug(f"{operation} Name: {name or '*'} Value: {value or '-'} SettingsType: {stype or '*'}")
|
|
79
|
-
atexit.register(self.settings.close)
|
|
80
|
-
with self.settings.open():
|
|
81
|
-
match operation:
|
|
82
|
-
case SetmanOps.LIST:
|
|
83
|
-
self._list_settings()
|
|
84
|
-
case SetmanOps.SEARCH:
|
|
85
|
-
self._search_settings(name or "%", stype, simple_fmt)
|
|
86
|
-
case SetmanOps.SET:
|
|
87
|
-
self._set_setting(name, value, stype)
|
|
88
|
-
case SetmanOps.GET:
|
|
89
|
-
self._get_setting(name, simple_fmt)
|
|
90
|
-
case SetmanOps.DEL:
|
|
91
|
-
self._del_setting(name)
|
|
92
|
-
case SetmanOps.TRUNCATE:
|
|
93
|
-
self._clear_settings()
|
|
94
|
-
|
|
95
|
-
def _set_setting(
|
|
96
|
-
self,
|
|
97
|
-
name: str | None,
|
|
98
|
-
value: Any | None,
|
|
99
|
-
stype: SettingsType = None,
|
|
100
|
-
) -> None:
|
|
101
|
-
found, entry = self.settings.upsert(name, value, stype)
|
|
102
|
-
sysout(f"%GREEN%Settings {'added' if not found else 'saved'}: %WHITE%", entry)
|
|
103
|
-
|
|
104
|
-
def _get_setting(self, name: str | None, simple_fmt: bool = False) -> None:
|
|
105
|
-
if found := self.settings.get(name):
|
|
106
|
-
sysout(found.to_string(simple_fmt))
|
|
107
|
-
else:
|
|
108
|
-
syserr("%EOL%%YELLOW%No settings found matching: %WHITE%", name)
|
|
109
|
-
|
|
110
|
-
def _del_setting(self, name: str | None) -> None:
|
|
111
|
-
if found := self.settings.remove(name):
|
|
112
|
-
sysout("%GREEN%Setting deleted: %WHITE%", found)
|
|
113
|
-
else:
|
|
114
|
-
syserr("%EOL%%YELLOW%No settings found matching: %WHITE%", name)
|
|
115
|
-
|
|
116
|
-
def _list_settings(self) -> None:
|
|
117
|
-
"""Display all settings."""
|
|
118
|
-
data = list(map(lambda s: s.values, self.settings.list()))
|
|
119
|
-
headers = ["uuid", "name", "value", "settings type", "modified"]
|
|
120
|
-
tr = TableRenderer(headers, data, "Systems Settings")
|
|
121
|
-
tr.adjust_auto_fit()
|
|
122
|
-
tr.set_header_alignment(TextAlignment.CENTER)
|
|
123
|
-
tr.set_cell_alignment(TextAlignment.LEFT)
|
|
124
|
-
tr.render()
|
|
125
|
-
|
|
126
|
-
def _search_settings(self, name: str, stype: SettingsType, simple_fmt: bool) -> None:
|
|
127
|
-
"""Search all settings matching criteria."""
|
|
128
|
-
data = self.settings.search(name, stype, simple_fmt)
|
|
129
|
-
sysout(os.linesep.join(data)) \
|
|
130
|
-
if data \
|
|
131
|
-
else sysout(
|
|
132
|
-
f"%EOL%%YELLOW%No settings found matching: %WHITE%[name={name.replace('%', '*')}, stype={stype}]"
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
def _clear_settings(self) -> None:
|
|
136
|
-
"""Clear all settings."""
|
|
137
|
-
sysout("%EOL%%ORANGE%All settings will be removed. Are you sure (y/[n])? ")
|
|
138
|
-
keystroke = Keyboard.wait_keystroke()
|
|
139
|
-
if keystroke and keystroke in [Keyboard.VK_y, Keyboard.VK_Y]:
|
|
140
|
-
self.settings.clear()
|
|
141
|
-
sysout("%EOL%%ORANGE%!!! All system settings have been removed !!!%EOL%")
|
|
142
|
-
|
|
143
|
-
def _setup(self, filepath: str) -> None:
|
|
144
|
-
"""Setup SetMan on the system."""
|
|
145
|
-
with open(filepath, "w+", encoding=Charset.UTF_8.val) as f_configs:
|
|
146
|
-
f_configs.write(f"hhs.setman.database = {self.SETMAN_DB_FILE} {os.linesep}")
|
|
147
|
-
f_configs.write(f"hhs.setman.encode.database = True")
|
|
148
|
-
check_state(os.path.exists(filepath), "Unable to create Setman configuration file: " + filepath)
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
"""
|
|
5
|
-
@project: HsPyLib-Clitt
|
|
6
|
-
@package: clitt.addons.setman
|
|
7
|
-
@file: setman_config.py
|
|
8
|
-
@created: Mon, 5 Jun 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 2023, HsPyLib team
|
|
14
|
-
"""
|
|
15
|
-
from hspylib.core.tools.commons import str_to_bool
|
|
16
|
-
|
|
17
|
-
from clitt.core.settings.settings_config import SettingsConfig
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class SetmanConfig(SettingsConfig):
|
|
21
|
-
"""Holds the SetMan configurations."""
|
|
22
|
-
|
|
23
|
-
def __init__(self, resource_dir: str, filename: str):
|
|
24
|
-
super().__init__(resource_dir, filename)
|
|
25
|
-
self._database: str = self["hhs.setman.database"]
|
|
26
|
-
self._encode_db: bool = str_to_bool(self["hhs.setman.encode.database"])
|