~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

Merge in bzr-dir phase 3, enabling controlled upgrades and shared repositories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
                 show_spinner=False,
70
70
                 show_eta=True,
71
71
                 show_bar=True,
72
 
                 show_count=True):
 
72
                 show_count=True,
 
73
                 to_messages_file=sys.stdout):
73
74
        object.__init__(self)
74
75
        self.to_file = to_file
75
 
 
 
76
        self.to_messages_file = to_messages_file
76
77
        self.last_msg = None
77
78
        self.last_cnt = None
78
79
        self.last_total = None
82
83
        self.show_bar = show_bar
83
84
        self.show_count = show_count
84
85
 
 
86
    def note(self, fmt_string, *args, **kwargs):
 
87
        """Record a note without disrupting the progress bar."""
 
88
        self.clear()
 
89
        self.to_messages_file.write(fmt_string % args)
 
90
        self.to_messages_file.write('\n')
85
91
 
86
92
 
87
93
class DummyProgress(_BaseProgressBar):
98
104
    def clear(self):
99
105
        pass
100
106
        
101
 
    
 
107
    def note(self, fmt_string, *args, **kwargs):
 
108
        """See _BaseProgressBar.note()."""
 
109
 
 
110
 
102
111
class DotsProgressBar(_BaseProgressBar):
103
112
    def __init__(self, **kwargs):
104
113
        _BaseProgressBar.__init__(self, **kwargs)
255
264
        self.to_file.write('\r' + m.ljust(self.width - 1))
256
265
        #self.to_file.flush()
257
266
            
258
 
 
259
267
    def clear(self):        
260
268
        self.to_file.write('\r%s\r' % (' ' * (self.width - 1)))
261
269
        #self.to_file.flush()        
262
 
    
263
270
 
264
271
        
265
272
def str_tdelta(delt):