/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: Martin Pool
  • Date: 2010-01-15 03:47:55 UTC
  • mto: This revision was merged to the branch mainline in revision 5019.
  • Revision ID: mbp@sourcefrog.net-20100115034755-y1sdgvlo6uplorg3
Delete old ChildProgress

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
231
231
        self.to_messages_file.write(fmt_string % args)
232
232
        self.to_messages_file.write('\n')
233
233
 
234
 
    @deprecated_function(deprecated_in((1, 16, 0)))
235
 
    def child_progress(self, **kwargs):
236
 
        return ChildProgress(**kwargs)
237
 
 
238
234
 
239
235
class DummyProgress(_BaseProgressBar):
240
236
    """Progress-bar standin that does nothing.
261
257
        return DummyProgress(**kwargs)
262
258
 
263
259
 
264
 
# DEPRECATED
265
 
class ChildProgress(_BaseProgressBar):
266
 
    """A progress indicator that pushes its data to the parent"""
267
 
 
268
 
    @deprecated_function(deprecated_in((1, 16, 0)))
269
 
    def __init__(self, _stack, **kwargs):
270
 
        _BaseProgressBar.__init__(self, _stack=_stack, **kwargs)
271
 
        self.parent = _stack.top()
272
 
        self.current = None
273
 
        self.total = None
274
 
        self.child_fraction = 0
275
 
        self.message = None
276
 
 
277
 
    def update(self, msg, current_cnt=None, total_cnt=None):
278
 
        self.current = current_cnt
279
 
        if total_cnt is not None:
280
 
            self.total = total_cnt
281
 
        self.message = msg
282
 
        self.child_fraction = 0
283
 
        self.tick()
284
 
 
285
 
    def child_update(self, message, current, total):
286
 
        if current is None or total == 0:
287
 
            self.child_fraction = 0
288
 
        else:
289
 
            self.child_fraction = float(current) / total
290
 
        self.tick()
291
 
 
292
 
    def tick(self):
293
 
        if self.current is None:
294
 
            count = None
295
 
        else:
296
 
            count = self.current+self.child_fraction
297
 
            if count > self.total:
298
 
                if __debug__:
299
 
                    mutter('clamping count of %d to %d' % (count, self.total))
300
 
                count = self.total
301
 
        self.parent.child_update(self.message, count, self.total)
302
 
 
303
 
    def clear(self):
304
 
        pass
305
 
 
306
 
    def note(self, *args, **kwargs):
307
 
        self.parent.note(*args, **kwargs)
308
 
 
309
 
 
310
260
def str_tdelta(delt):
311
261
    if delt is None:
312
262
        return "-:--:--"