~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

Hacking notes on TDD

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
from collections import deque
43
43
 
44
44
 
 
45
def _width():
 
46
    """Return estimated terminal width.
 
47
 
 
48
    TODO: Do something smart on Windows?
 
49
 
 
50
    TODO: Is there anything that gets a better update when the window
 
51
          is resized while the program is running?
 
52
    """
 
53
    try:
 
54
        return int(os.environ['COLUMNS'])
 
55
    except (IndexError, KeyError, ValueError):
 
56
        return 80
 
57
 
 
58
 
45
59
def _supports_progress(f):
46
60
    if not hasattr(f, 'isatty'):
47
61
        return False
148
162
 
149
163
 
150
164
    def __init__(self, **kwargs):
151
 
        from bzrlib.osutils import terminal_width
152
165
        _BaseProgressBar.__init__(self, **kwargs)
153
166
        self.spin_pos = 0
154
 
        self.width = terminal_width()
 
167
        self.width = _width()
155
168
        self.start_time = None
156
169
        self.last_update = None
157
170
        self.last_updates = deque()