166
166
return _progress_bar_types[requested_bar_type](to_file=to_file, **kwargs)
169
class ProgressBarStack(object):
170
"""A stack of progress bars.
172
This class is deprecated: instead, ask the ui factory for a new progress
173
task and finish it when it's done.
176
@deprecated_method(deprecated_in((1, 12, 0)))
184
to_messages_file=None,
186
"""Setup the stack with the parameters the progress bars should have."""
189
if to_messages_file is None:
190
to_messages_file = sys.stdout
191
self._to_file = to_file
192
self._show_pct = show_pct
193
self._show_spinner = show_spinner
194
self._show_eta = show_eta
195
self._show_bar = show_bar
196
self._show_count = show_count
197
self._to_messages_file = to_messages_file
199
self._klass = klass or ProgressBar
202
if len(self._stack) != 0:
203
return self._stack[-1]
208
if len(self._stack) != 0:
209
return self._stack[0]
213
def get_nested(self):
214
"""Return a nested progress bar."""
215
if len(self._stack) == 0:
218
func = self.top().child_progress
219
new_bar = func(to_file=self._to_file,
220
show_pct=self._show_pct,
221
show_spinner=self._show_spinner,
222
show_eta=self._show_eta,
223
show_bar=self._show_bar,
224
show_count=self._show_count,
225
to_messages_file=self._to_messages_file,
227
self._stack.append(new_bar)
230
def return_pb(self, bar):
231
"""Return bar after its been used."""
232
if bar is not self._stack[-1]:
233
warnings.warn("%r is not currently active" % (bar,))
238
169
class _BaseProgressBar(object):
240
171
def __init__(self,