@@ -77,6 +77,15 @@ def __init__(
77
77
stream : io, optional
78
78
Output.
79
79
"""
80
+
81
+ # To reset Values in deleter
82
+ self .reset_values = {"text" : text ,
83
+ "color" : color ,
84
+ "text_color" : text_color ,
85
+ "spinner" : spinner ,
86
+ "animation" : animation ,
87
+ "placement" : placement ,}
88
+
80
89
self ._color = color
81
90
self ._animation = animation
82
91
@@ -156,6 +165,12 @@ def spinner(self, spinner=None):
156
165
self ._frame_index = 0
157
166
self ._text_index = 0
158
167
168
+ @spinner .deleter
169
+ def spinner (self ):
170
+ """set spinner to None when delete spinner is
171
+ """
172
+ self ._spinner = self .reset_values ["spinner" ]
173
+
159
174
@property
160
175
def text (self ):
161
176
"""Getter for text property.
@@ -176,6 +191,10 @@ def text(self, text):
176
191
"""
177
192
self ._text = self ._get_text (text )
178
193
194
+ @text .deleter
195
+ def text (self ):
196
+ self .text = self .reset_values ["text" ]
197
+
179
198
@property
180
199
def text_color (self ):
181
200
"""Getter for text color property.
@@ -196,6 +215,10 @@ def text_color(self, text_color):
196
215
"""
197
216
self ._text_color = text_color
198
217
218
+ @text_color .deleter
219
+ def text_color (self ):
220
+ self ._text_color = self .reset_values ["text_color" ]
221
+
199
222
@property
200
223
def color (self ):
201
224
"""Getter for color property.
@@ -216,6 +239,10 @@ def color(self, color):
216
239
"""
217
240
self ._color = color
218
241
242
+ @color .deleter
243
+ def color (self ):
244
+ self ._color = self .reset_values ["color" ]
245
+
219
246
@property
220
247
def placement (self ):
221
248
"""Getter for placement property.
@@ -242,6 +269,10 @@ def placement(self, placement):
242
269
)
243
270
self ._placement = placement
244
271
272
+ @placement .deleter
273
+ def placement (self ):
274
+ self .placement = self .reset_values ["placement" ]
275
+
245
276
@property
246
277
def spinner_id (self ):
247
278
"""Getter for spinner id
@@ -273,6 +304,10 @@ def animation(self, animation):
273
304
self ._animation = animation
274
305
self ._text = self ._get_text (self ._text ["original" ])
275
306
307
+ @animation .deleter
308
+ def animation (self ):
309
+ self ._animation = self .reset_values ["animation" ]
310
+
276
311
def _check_stream (self ):
277
312
"""Returns whether the stream is open, and if applicable, writable
278
313
Returns
@@ -334,10 +369,7 @@ def _get_spinner(self, spinner):
334
369
return spinner
335
370
336
371
if is_supported ():
337
- if all ([is_text_type (spinner ), spinner in Spinners .__members__ ]):
338
- return Spinners [spinner ].value
339
- else :
340
- return default_spinner
372
+ return Spinners [spinner ].valueif if all ([is_text_type (spinner ), spinner in Spinners .__members__ ]) else default_spinner
341
373
else :
342
374
return Spinners ["line" ].value
343
375
@@ -354,8 +386,8 @@ def _get_text(self, text):
354
386
max_spinner_length = max ([len (i ) for i in self ._spinner ["frames" ]])
355
387
356
388
# Subtract to the current terminal size the max spinner length
357
- # (- 1 to leave room for the extra space between spinner and text)
358
- terminal_width = get_terminal_columns () - max_spinner_length - 1
389
+ # (+ 1 to leave room for the extra space between spinner and text)
390
+ terminal_width = get_terminal_columns () - ( max_spinner_length + 1 )
359
391
text_length = len (stripped_text )
360
392
361
393
frames = []
0 commit comments