~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/text.py

  • Committer: Martin Pool
  • Date: 2009-03-12 06:53:33 UTC
  • mto: This revision was merged to the branch mainline in revision 4144.
  • Revision ID: mbp@sourcefrog.net-20090312065333-h0kotewsx4l52gqs
Refactor TextProgressView a bit and add another test

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
            spin_str =  r'/-\|'[self._spin_pos % 4]
155
155
            self._spin_pos += 1
156
156
            cols = 20
157
 
            # number of markers highlighted in bar
158
 
            completion_fraction = self._last_task._overall_completion_fraction()
 
157
            completion_fraction = \
 
158
                self._last_task._overall_completion_fraction() or 0
159
159
            markers = int(round(float(cols) * completion_fraction)) - 1
160
160
            bar_str = '[' + ('#' * markers + spin_str).ljust(cols) + '] '
161
161
            return bar_str
185
185
                m = t.msg + ':' + m
186
186
        return m + s
187
187
 
188
 
    def _repaint(self):
 
188
    def _render_line(self):
189
189
        bar_string = self._render_bar()
190
190
        if self._last_task:
191
191
            task_msg = self._format_task(self._last_task)
192
192
        else:
193
193
            task_msg = ''
194
194
        trans = self._last_transport_msg
195
 
        if trans and task_msg:
 
195
        if trans:
196
196
            trans += ' | '
197
 
        s = (bar_string
198
 
             + trans
199
 
             + task_msg
200
 
             )
 
197
        return (bar_string + trans + task_msg)
 
198
 
 
199
    def _repaint(self):
 
200
        s = self._render_line()
201
201
        self._show_line(s)
202
202
        self._have_output = True
203
203