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 CHANGED
@@ -8,7 +8,7 @@ import readchar
8
8
  _console = Console()
9
9
 
10
10
  def _style(
11
- text,
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(text):
27
- message = Text()
28
- if isinstance(text, str):
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 text:
37
+ for character in object:
38
38
  if character == " ":
39
39
  if current_segment:
40
- message.append(current_segment, style = style)
40
+ styleable.append(current_segment, style = style)
41
41
  current_segment = ""
42
- message.append(" ")
42
+ styleable.append(" ")
43
43
  else: current_segment += character
44
- if current_segment: message.append(current_segment, style=style)
45
- return message
46
- elif isinstance(text, list):
47
- for segment, segment_style in text:
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
- message.append(current_segment, style = style)
59
+ styleable.append(current_segment, style = style)
60
60
  current_segment = ""
61
- message.append(" ")
61
+ styleable.append(" ")
62
62
  else: current_segment += character
63
- if current_segment: message.append(current_segment, style = style)
64
- return message
63
+ if current_segment: styleable.append(current_segment, style = style)
64
+ return styleable
65
65
 
66
- def apply_alignment(message): return Align(message, alignment)
66
+ def apply_alignment(alignable): return Align(alignable, alignment)
67
67
 
68
- def apply_padding(message):
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(message, final_padding)
75
+ return Padding(paddable, final_padding)
76
76
 
77
- message = apply_text_styles(text)
78
- if plain_text: return message
79
- message = apply_alignment(message)
80
- message = apply_padding(message)
81
- return message
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
- text = object,
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): renderables.append(object)
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
- text = str(object),
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
- text = text,
167
+ object = text,
153
168
  color = color,
154
169
  bold = bold,
155
170
  italic = italic,
@@ -21,7 +21,7 @@ def menu(
21
21
  title,
22
22
  title_color = "#ffffff",
23
23
  title_bold = True,
24
- title_italic = False,
24
+ title_italic = True,
25
25
  title_underline = False,
26
26
  title_strike = False,
27
27
  title_reverse = False,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tui_utilities
3
- Version: 1.0.14
3
+ Version: 1.0.16
4
4
  Summary: Personal-use console utilities library
5
5
  Author-email: Guido Iván Gross <grossguidoivan@gmail.com>
6
6
  License: MIT
@@ -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,,