tui-utilities 1.0.6__tar.gz → 1.0.7__tar.gz
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.
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/PKG-INFO +1 -1
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/pyproject.toml +1 -1
- tui_utilities-1.0.7/tui_utilities/structure.py +115 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities.egg-info/PKG-INFO +1 -1
- tui_utilities-1.0.6/tui_utilities/structure.py +0 -58
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/README.md +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/setup.cfg +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities/__init__.py +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities/_tlds/tlds.txt +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities/console.py +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities/format.py +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities/validation.py +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities.egg-info/SOURCES.txt +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities.egg-info/dependency_links.txt +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities.egg-info/requires.txt +0 -0
- {tui_utilities-1.0.6 → tui_utilities-1.0.7}/tui_utilities.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
from .console import print, input
|
|
2
|
+
import sys
|
|
3
|
+
import traceback
|
|
4
|
+
|
|
5
|
+
def _choose_option(
|
|
6
|
+
options,
|
|
7
|
+
message = "Seleccione una opción:",
|
|
8
|
+
selection_text = "Su elección: ",
|
|
9
|
+
error = "La opción ingresada no es válida, intente nuevamente",
|
|
10
|
+
):
|
|
11
|
+
print(f"{message}\n", bold = True)
|
|
12
|
+
for key, option in options.items(): print([(f"{key}:", {"bold": True}), (f" {option}", {})])
|
|
13
|
+
selection = input(f"\n{selection_text}", bold = True).upper()
|
|
14
|
+
while selection not in options:
|
|
15
|
+
print(f"\n{error}\n", color = "#ff0000")
|
|
16
|
+
selection = input(f"\n{selection_text}", bold = True).upper()
|
|
17
|
+
return selection
|
|
18
|
+
|
|
19
|
+
def menu(
|
|
20
|
+
options_list,
|
|
21
|
+
message = "Seleccione una opción:",
|
|
22
|
+
selection_text = "Su elección: ",
|
|
23
|
+
error = "La opción ingresada no es válida, intente nuevamente"
|
|
24
|
+
):
|
|
25
|
+
options = {}
|
|
26
|
+
key = 1
|
|
27
|
+
for option in options_list:
|
|
28
|
+
match option:
|
|
29
|
+
case "Atrás": options["A"] = option
|
|
30
|
+
case "Salir": options["S"] = option
|
|
31
|
+
case _:
|
|
32
|
+
options[str(key)] = option
|
|
33
|
+
key += 1
|
|
34
|
+
return _choose_option(options, message, selection_text, error)
|
|
35
|
+
|
|
36
|
+
def confirm_exit(
|
|
37
|
+
message = "¿Está seguro de querer salir?",
|
|
38
|
+
selection_text = "Su elección: ",
|
|
39
|
+
error = "La opción ingresada no es válida, intente nuevamente",
|
|
40
|
+
options_text = ["Sí", "No"]
|
|
41
|
+
):
|
|
42
|
+
options = {
|
|
43
|
+
"1": options_text[0],
|
|
44
|
+
"2": options_text[1]
|
|
45
|
+
}
|
|
46
|
+
selection = _choose_option(options, f"\n{message}", selection_text, error)
|
|
47
|
+
if selection == "1": sys.exit()
|
|
48
|
+
|
|
49
|
+
def separator(
|
|
50
|
+
length = 100,
|
|
51
|
+
color = "#ffffff",
|
|
52
|
+
aligment = "left",
|
|
53
|
+
padding = 0,
|
|
54
|
+
top_padding = None,
|
|
55
|
+
right_padding = None,
|
|
56
|
+
bottom_padding = None,
|
|
57
|
+
left_padding = None
|
|
58
|
+
):
|
|
59
|
+
print(object = "/" + "-" * length + "/",
|
|
60
|
+
color = color,
|
|
61
|
+
bold = True,
|
|
62
|
+
alignment = aligment,
|
|
63
|
+
padding = padding,
|
|
64
|
+
top_padding = top_padding,
|
|
65
|
+
right_padding = right_padding,
|
|
66
|
+
bottom_padding = bottom_padding,
|
|
67
|
+
left_padding = left_padding
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
def error_message(
|
|
71
|
+
message,
|
|
72
|
+
error,
|
|
73
|
+
separator_length = 100,
|
|
74
|
+
separator_color = "#ffffff",
|
|
75
|
+
separator_aligment = "left",
|
|
76
|
+
separator_padding = 0,
|
|
77
|
+
separator_top_padding = None,
|
|
78
|
+
separator_right_padding = None,
|
|
79
|
+
separator_bottom_padding = None,
|
|
80
|
+
separator_left_padding = None
|
|
81
|
+
):
|
|
82
|
+
print(f"{message}\n", color = "#ff0000", bold = True)
|
|
83
|
+
separator(
|
|
84
|
+
length = separator_length,
|
|
85
|
+
color = separator_color,
|
|
86
|
+
aligment = separator_aligment,
|
|
87
|
+
padding = separator_padding,
|
|
88
|
+
top_padding = separator_top_padding,
|
|
89
|
+
right_padding = separator_right_padding,
|
|
90
|
+
bottom_padding = separator_bottom_padding,
|
|
91
|
+
left_padding = separator_left_padding
|
|
92
|
+
)
|
|
93
|
+
print(f"Error: {error}", bold = True)
|
|
94
|
+
separator(
|
|
95
|
+
length = separator_length,
|
|
96
|
+
color = separator_color,
|
|
97
|
+
aligment = separator_aligment,
|
|
98
|
+
padding = separator_padding,
|
|
99
|
+
top_padding = separator_top_padding,
|
|
100
|
+
right_padding = separator_right_padding,
|
|
101
|
+
bottom_padding = separator_bottom_padding,
|
|
102
|
+
left_padding = separator_left_padding
|
|
103
|
+
)
|
|
104
|
+
print("Detalles:\n", bold = True)
|
|
105
|
+
print(traceback.format_exc(), color = "#00bfff")
|
|
106
|
+
separator(
|
|
107
|
+
length = separator_length,
|
|
108
|
+
color = separator_color,
|
|
109
|
+
aligment = separator_aligment,
|
|
110
|
+
padding = separator_padding,
|
|
111
|
+
top_padding = separator_top_padding,
|
|
112
|
+
right_padding = separator_right_padding,
|
|
113
|
+
bottom_padding = separator_bottom_padding,
|
|
114
|
+
left_padding = separator_left_padding
|
|
115
|
+
)
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
from .console import print, input
|
|
2
|
-
import sys
|
|
3
|
-
import traceback
|
|
4
|
-
|
|
5
|
-
def _choose_option(
|
|
6
|
-
options,
|
|
7
|
-
message = "Seleccione una opción:",
|
|
8
|
-
selection_text = "Su elección: ",
|
|
9
|
-
error = "La opción ingresada no es válida, intente nuevamente",
|
|
10
|
-
):
|
|
11
|
-
print(f"{message}\n", bold = True)
|
|
12
|
-
for key, option in options.items(): print([(f"{key}:", {"bold": True}), (f" {option}", {})])
|
|
13
|
-
selection = input(f"\n{selection_text}", bold = True).upper()
|
|
14
|
-
while selection not in options:
|
|
15
|
-
print(f"\n{error}\n", color = "#ff0000")
|
|
16
|
-
selection = input(f"\n{selection_text}", bold = True).upper()
|
|
17
|
-
return selection
|
|
18
|
-
|
|
19
|
-
def menu(
|
|
20
|
-
options_list,
|
|
21
|
-
message = "Seleccione una opción:",
|
|
22
|
-
selection_text = "Su elección: ",
|
|
23
|
-
error = "La opción ingresada no es válida, intente nuevamente"
|
|
24
|
-
):
|
|
25
|
-
options = {}
|
|
26
|
-
key = 1
|
|
27
|
-
for option in options_list:
|
|
28
|
-
match option:
|
|
29
|
-
case "Atrás": options["A"] = option
|
|
30
|
-
case "Salir": options["S"] = option
|
|
31
|
-
case _:
|
|
32
|
-
options[str(key)] = option
|
|
33
|
-
key += 1
|
|
34
|
-
return _choose_option(options, message, selection_text, error)
|
|
35
|
-
|
|
36
|
-
def confirm_exit(
|
|
37
|
-
message = "¿Está seguro de querer salir?",
|
|
38
|
-
selection_text = "Su elección: ",
|
|
39
|
-
error = "La opción ingresada no es válida, intente nuevamente",
|
|
40
|
-
options_text = ["Sí", "No"]
|
|
41
|
-
):
|
|
42
|
-
options = {
|
|
43
|
-
"1": options_text[0],
|
|
44
|
-
"2": options_text[1]
|
|
45
|
-
}
|
|
46
|
-
selection = _choose_option(options, f"\n{message}", selection_text, error)
|
|
47
|
-
if selection == "1": sys.exit()
|
|
48
|
-
|
|
49
|
-
def separator(length = 100): print("/" + "-" * length + "/", bold = True)
|
|
50
|
-
|
|
51
|
-
def error_message(message, error):
|
|
52
|
-
print(f"{message}\n", color = "#ff0000", bold = True)
|
|
53
|
-
separator()
|
|
54
|
-
print(f"Error: {error}", bold = True)
|
|
55
|
-
separator()
|
|
56
|
-
print("Detalles:\n", bold = True)
|
|
57
|
-
print(traceback.format_exc(), color = "#00bfff")
|
|
58
|
-
separator()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|