~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

Fixup pb usage to use nested_progress_bar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
                 show_eta=True,
76
76
                 show_bar=True,
77
77
                 show_count=True,
78
 
                 to_messages_file=sys.stdout):
 
78
                 to_messages_file=sys.stdout,
 
79
                 klass=None):
79
80
        """Setup the stack with the parameters the progress bars should have."""
80
81
        self._to_file = to_file
81
82
        self._show_pct = show_pct
85
86
        self._show_count = show_count
86
87
        self._to_messages_file = to_messages_file
87
88
        self._stack = []
 
89
        self._klass = klass or TTYProgressBar
88
90
 
89
91
    def get_nested(self):
90
92
        """Return a nested progress bar."""
91
93
        # initial implementation - return a new bar each time.
92
 
        new_bar = TTYProgressBar(to_file=self._to_file,
93
 
                                 show_pct=self._show_pct,
94
 
                                 show_spinner=self._show_spinner,
95
 
                                 show_eta=self._show_eta,
96
 
                                 show_bar=self._show_bar,
97
 
                                 show_count=self._show_count,
98
 
                                 to_messages_file=self._to_messages_file,
99
 
                                 _stack=self)
 
94
        new_bar = self._klass(to_file=self._to_file,
 
95
                              show_pct=self._show_pct,
 
96
                              show_spinner=self._show_spinner,
 
97
                              show_eta=self._show_eta,
 
98
                              show_bar=self._show_bar,
 
99
                              show_count=self._show_count,
 
100
                              to_messages_file=self._to_messages_file,
 
101
                              _stack=self)
100
102
        self._stack.append(new_bar)
101
103
        return new_bar
102
104
 
134
136
    def finished(self):
135
137
        """Return this bar to its progress stack."""
136
138
        self.clear()
137
 
        assert self._stack
 
139
        assert self._stack is not None
138
140
        self._stack.return_pb(self)
139
141
 
140
142
    def note(self, fmt_string, *args, **kwargs):
163
165
 
164
166
 
165
167
class DotsProgressBar(_BaseProgressBar):
 
168
 
166
169
    def __init__(self, **kwargs):
167
170
        _BaseProgressBar.__init__(self, **kwargs)
168
171
        self.last_msg = None