~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: Aaron Bentley
  • Date: 2005-10-03 16:53:39 UTC
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: abentley@panoramicfeedback.com-20051003165339-9ee4d484477fd164
Ignored user-installed plugins

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
        self.show_eta = show_eta
95
95
        self.show_bar = show_bar
96
96
        self.show_count = show_count
97
 
        
 
97
 
 
98
 
 
99
 
 
100
class DummyProgress(_BaseProgressBar):
 
101
    """Progress-bar standin that does nothing.
 
102
 
 
103
    This can be used as the default argument for methods that
 
104
    take an optional progress indicator."""
 
105
    def tick(self):
 
106
        pass
 
107
 
 
108
    def update(self, msg=None, current=None, total=None):
 
109
        pass
 
110
 
 
111
    def clear(self):
 
112
        pass
98
113
        
99
114
    
100
115
class DotsProgressBar(_BaseProgressBar):
176
191
    def update(self, msg, current_cnt=None, total_cnt=None):
177
192
        """Update and redraw progress bar."""
178
193
 
 
194
        if current_cnt < 0:
 
195
            current_cnt = 0
 
196
            
 
197
        if current_cnt > total_cnt:
 
198
            total_cnt = current_cnt
 
199
 
179
200
        # save these for the tick() function
180
201
        self.last_msg = msg
181
202
        self.last_cnt = current_cnt
184
205
        if self.throttle():
185
206
            return 
186
207
        
187
 
        if total_cnt:
188
 
            assert current_cnt <= total_cnt
189
 
        if current_cnt:
190
 
            assert current_cnt >= 0
191
 
        
192
208
        if self.show_eta and self.start_time and total_cnt:
193
209
            eta = get_eta(self.start_time, current_cnt, total_cnt)
194
210
            eta_str = " " + str_tdelta(eta)