~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: Martin Pool
  • Date: 2009-06-05 22:46:47 UTC
  • mto: This revision was merged to the branch mainline in revision 4418.
  • Revision ID: mbp@sourcefrog.net-20090605224647-k03yoq55uw1qhwvi
Remove ProgressBarStack and its tests deprecated since 1.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
166
166
        return _progress_bar_types[requested_bar_type](to_file=to_file, **kwargs)
167
167
 
168
168
 
169
 
class ProgressBarStack(object):
170
 
    """A stack of progress bars.
171
 
 
172
 
    This class is deprecated: instead, ask the ui factory for a new progress
173
 
    task and finish it when it's done.
174
 
    """
175
 
 
176
 
    @deprecated_method(deprecated_in((1, 12, 0)))
177
 
    def __init__(self,
178
 
                 to_file=None,
179
 
                 show_pct=False,
180
 
                 show_spinner=True,
181
 
                 show_eta=False,
182
 
                 show_bar=True,
183
 
                 show_count=True,
184
 
                 to_messages_file=None,
185
 
                 klass=None):
186
 
        """Setup the stack with the parameters the progress bars should have."""
187
 
        if to_file is None:
188
 
            to_file = sys.stderr
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
198
 
        self._stack = []
199
 
        self._klass = klass or ProgressBar
200
 
 
201
 
    def top(self):
202
 
        if len(self._stack) != 0:
203
 
            return self._stack[-1]
204
 
        else:
205
 
            return None
206
 
 
207
 
    def bottom(self):
208
 
        if len(self._stack) != 0:
209
 
            return self._stack[0]
210
 
        else:
211
 
            return None
212
 
 
213
 
    def get_nested(self):
214
 
        """Return a nested progress bar."""
215
 
        if len(self._stack) == 0:
216
 
            func = self._klass
217
 
        else:
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,
226
 
                       _stack=self)
227
 
        self._stack.append(new_bar)
228
 
        return new_bar
229
 
 
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,))
234
 
        else:
235
 
            self._stack.pop()
236
 
 
237
 
 
238
169
class _BaseProgressBar(object):
239
170
 
240
171
    def __init__(self,
362
293
    """
363
294
    SPIN_CHARS = r'/-\|'
364
295
 
365
 
 
366
296
    def __init__(self, **kwargs):
367
297
        from bzrlib.osutils import terminal_width
368
298
        _BaseProgressBar.__init__(self, **kwargs)