tui-utilities 1.0.14__py3-none-any.whl → 1.0.16__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.
- tui_utilities/console.py +42 -27
- tui_utilities/structure.py +1 -1
- {tui_utilities-1.0.14.dist-info → tui_utilities-1.0.16.dist-info}/METADATA +1 -1
- tui_utilities-1.0.16.dist-info/RECORD +10 -0
- tui_utilities-1.0.14.dist-info/RECORD +0 -10
- {tui_utilities-1.0.14.dist-info → tui_utilities-1.0.16.dist-info}/WHEEL +0 -0
- {tui_utilities-1.0.14.dist-info → tui_utilities-1.0.16.dist-info}/top_level.txt +0 -0
tui_utilities/console.py
CHANGED
|
@@ -8,7 +8,7 @@ import readchar
|
|
|
8
8
|
_console = Console()
|
|
9
9
|
|
|
10
10
|
def _style(
|
|
11
|
-
|
|
11
|
+
object,
|
|
12
12
|
color = "#ffffff",
|
|
13
13
|
bold = False,
|
|
14
14
|
italic = False,
|
|
@@ -23,9 +23,9 @@ def _style(
|
|
|
23
23
|
left_padding = None,
|
|
24
24
|
plain_text = False
|
|
25
25
|
):
|
|
26
|
-
def apply_text_styles(
|
|
27
|
-
|
|
28
|
-
if isinstance(
|
|
26
|
+
def apply_text_styles(object):
|
|
27
|
+
styleable = Text()
|
|
28
|
+
if isinstance(object, str):
|
|
29
29
|
style_parts = [color]
|
|
30
30
|
if bold: style_parts.append("bold")
|
|
31
31
|
if italic: style_parts.append("italic")
|
|
@@ -34,17 +34,17 @@ def _style(
|
|
|
34
34
|
if reverse: style_parts.append("reverse")
|
|
35
35
|
style = " ".join(style_parts)
|
|
36
36
|
current_segment = ""
|
|
37
|
-
for character in
|
|
37
|
+
for character in object:
|
|
38
38
|
if character == " ":
|
|
39
39
|
if current_segment:
|
|
40
|
-
|
|
40
|
+
styleable.append(current_segment, style = style)
|
|
41
41
|
current_segment = ""
|
|
42
|
-
|
|
42
|
+
styleable.append(" ")
|
|
43
43
|
else: current_segment += character
|
|
44
|
-
if current_segment:
|
|
45
|
-
return
|
|
46
|
-
elif isinstance(
|
|
47
|
-
for segment, segment_style in
|
|
44
|
+
if current_segment: styleable.append(current_segment, style=style)
|
|
45
|
+
return styleable
|
|
46
|
+
elif isinstance(object, list):
|
|
47
|
+
for segment, segment_style in object:
|
|
48
48
|
style_parts = [segment_style.get("color", color)]
|
|
49
49
|
if segment_style.get("bold"): style_parts.append("bold")
|
|
50
50
|
if segment_style.get("italic"): style_parts.append("italic")
|
|
@@ -56,29 +56,35 @@ def _style(
|
|
|
56
56
|
for character in segment:
|
|
57
57
|
if character == " ":
|
|
58
58
|
if current_segment:
|
|
59
|
-
|
|
59
|
+
styleable.append(current_segment, style = style)
|
|
60
60
|
current_segment = ""
|
|
61
|
-
|
|
61
|
+
styleable.append(" ")
|
|
62
62
|
else: current_segment += character
|
|
63
|
-
if current_segment:
|
|
64
|
-
return
|
|
63
|
+
if current_segment: styleable.append(current_segment, style = style)
|
|
64
|
+
return styleable
|
|
65
65
|
|
|
66
|
-
def apply_alignment(
|
|
66
|
+
def apply_alignment(alignable): return Align(alignable, alignment)
|
|
67
67
|
|
|
68
|
-
def apply_padding(
|
|
68
|
+
def apply_padding(paddable):
|
|
69
69
|
final_padding = (
|
|
70
70
|
top_padding if top_padding is not None else padding,
|
|
71
71
|
(right_padding if right_padding is not None else padding) * 2,
|
|
72
72
|
bottom_padding if bottom_padding is not None else padding,
|
|
73
73
|
(left_padding if left_padding is not None else padding) * 2
|
|
74
74
|
)
|
|
75
|
-
return Padding(
|
|
75
|
+
return Padding(paddable, final_padding)
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
if isinstance(object, RenderableType):
|
|
78
|
+
aligned = apply_alignment(object)
|
|
79
|
+
padded = apply_padding(aligned)
|
|
80
|
+
return padded
|
|
81
|
+
elif plain_text:
|
|
82
|
+
styled = apply_text_styles(object)
|
|
83
|
+
return styled
|
|
84
|
+
styled = apply_text_styles(object)
|
|
85
|
+
aligned = apply_alignment(styled)
|
|
86
|
+
padded = apply_padding(aligned)
|
|
87
|
+
return padded
|
|
82
88
|
|
|
83
89
|
def print(
|
|
84
90
|
*objects,
|
|
@@ -104,7 +110,7 @@ def print(
|
|
|
104
110
|
if isinstance(object, Text): renderables.append(object)
|
|
105
111
|
elif isinstance(object, (str, list)):
|
|
106
112
|
renderables.append(_style(
|
|
107
|
-
|
|
113
|
+
object = object,
|
|
108
114
|
color = color,
|
|
109
115
|
bold = bold,
|
|
110
116
|
italic = italic,
|
|
@@ -119,10 +125,19 @@ def print(
|
|
|
119
125
|
left_padding = left_padding,
|
|
120
126
|
plain_text = plain_text
|
|
121
127
|
))
|
|
122
|
-
elif isinstance(object, RenderableType):
|
|
128
|
+
elif isinstance(object, RenderableType):
|
|
129
|
+
renderables.append(_style(
|
|
130
|
+
object = object,
|
|
131
|
+
alignment = alignment,
|
|
132
|
+
padding = padding,
|
|
133
|
+
top_padding = top_padding,
|
|
134
|
+
right_padding = right_padding,
|
|
135
|
+
bottom_padding = bottom_padding,
|
|
136
|
+
left_padding = left_padding
|
|
137
|
+
))
|
|
123
138
|
else:
|
|
124
139
|
renderables.append(_style(
|
|
125
|
-
|
|
140
|
+
object = str(object),
|
|
126
141
|
color = color,
|
|
127
142
|
bold = bold,
|
|
128
143
|
italic = italic,
|
|
@@ -149,7 +164,7 @@ def input(
|
|
|
149
164
|
reverse = False
|
|
150
165
|
):
|
|
151
166
|
return _console.input(_style(
|
|
152
|
-
|
|
167
|
+
object = text,
|
|
153
168
|
color = color,
|
|
154
169
|
bold = bold,
|
|
155
170
|
italic = italic,
|
tui_utilities/structure.py
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
tui_utilities/__init__.py,sha256=8WIoKhRFLM4Bcdd7W3grDoBgfSR0HFWxTsP4ON6Il-E,775
|
|
2
|
+
tui_utilities/console.py,sha256=cocqR7Qogvnx2goeK6Xb6-LUfVy09MUjgkM6y8ps50k,6997
|
|
3
|
+
tui_utilities/format.py,sha256=6Ou6aeRku1Fb5Nf0tKmCgh8CIsh3sRJZogog-f5_igc,657
|
|
4
|
+
tui_utilities/structure.py,sha256=yFbKhUagXfaFcQgyu5MX-Tjpp47aKir4K2jdJSBfdJo,5241
|
|
5
|
+
tui_utilities/validation.py,sha256=xybjpleTg0l7lRT0D3QuD62_RwV-r03ZTwPqO9us9Tg,6511
|
|
6
|
+
tui_utilities/_tlds/tlds.txt,sha256=ieHVMCtLqEoh8aiMZIZPepNdOjR3CGlO2QgH5LKCRuI,10916
|
|
7
|
+
tui_utilities-1.0.16.dist-info/METADATA,sha256=zQa-7c26IBr_mt8k-KQPF6aO_SMypIRbMglsV_oQM-s,4250
|
|
8
|
+
tui_utilities-1.0.16.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
9
|
+
tui_utilities-1.0.16.dist-info/top_level.txt,sha256=TF1KuV0fMB1rkFRhqaCkqjprAnH-Tpc4Klsxwif5RWI,14
|
|
10
|
+
tui_utilities-1.0.16.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
tui_utilities/__init__.py,sha256=8WIoKhRFLM4Bcdd7W3grDoBgfSR0HFWxTsP4ON6Il-E,775
|
|
2
|
-
tui_utilities/console.py,sha256=5HLZXOVeiGnJ8auX1CBEA8rHCw3A88Ou-fxaK_J-xrE,6426
|
|
3
|
-
tui_utilities/format.py,sha256=6Ou6aeRku1Fb5Nf0tKmCgh8CIsh3sRJZogog-f5_igc,657
|
|
4
|
-
tui_utilities/structure.py,sha256=2Trto4nbTdU4AlnVFKSGMNNwO9XjXRVILdQS584EzVI,5242
|
|
5
|
-
tui_utilities/validation.py,sha256=xybjpleTg0l7lRT0D3QuD62_RwV-r03ZTwPqO9us9Tg,6511
|
|
6
|
-
tui_utilities/_tlds/tlds.txt,sha256=ieHVMCtLqEoh8aiMZIZPepNdOjR3CGlO2QgH5LKCRuI,10916
|
|
7
|
-
tui_utilities-1.0.14.dist-info/METADATA,sha256=vKos76QygeUBq2_nc5MAFsjVFQJprYP6jfJiS-O_eNA,4250
|
|
8
|
-
tui_utilities-1.0.14.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
9
|
-
tui_utilities-1.0.14.dist-info/top_level.txt,sha256=TF1KuV0fMB1rkFRhqaCkqjprAnH-Tpc4Klsxwif5RWI,14
|
|
10
|
-
tui_utilities-1.0.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|