~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: Martin Pool
  • Date: 2005-06-10 07:22:19 UTC
  • Revision ID: mbp@sourcefrog.net-20050610072219-de162df990d2d85d
- better calculation of progress bar position

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
# indicators, preferably without needing to adjust all code that
36
36
# potentially calls them.
37
37
 
 
38
# TODO: Perhaps don't write updates faster than a certain rate, say
 
39
# 5/second.
 
40
 
38
41
 
39
42
import sys
40
43
import datetime
156
159
    cols = _width() - 3 - len(f)
157
160
    if start_time is not None:
158
161
        cols -= len(eta_str)
159
 
    markers = int (float(cols) * progress.current / progress.total)
 
162
    markers = int(round(float(cols) * progress.current / progress.total))
160
163
    txt = fmt % (progress.current, progress.total, progress.units,
161
164
                 progress.percent)
162
165
    to_file.write("\r[%s%s]%s%s" % ('='*markers, ' '*(cols-markers), txt,