~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: Martin Pool
  • Date: 2008-12-15 08:28:57 UTC
  • mto: (3882.7.11 progress)
  • mto: This revision was merged to the branch mainline in revision 3940.
  • Revision ID: mbp@sourcefrog.net-20081215082857-asjzld70e2s1i0ta
Change progress bars to a more MVC style

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
 
51
51
    def __init__(self):
52
52
        super(UIFactory, self).__init__()
53
 
        self._progress_bar_stack = None
 
53
        self._task_stack = []
54
54
 
55
55
    def get_password(self, prompt='', **kwargs):
56
56
        """Prompt the user for a password.
73
73
        When the bar has been finished with, it should be released by calling
74
74
        bar.finished().
75
75
        """
76
 
        raise NotImplementedError(self.nested_progress_bar)
 
76
        if self._task_stack:
 
77
            t = progress.ProgressTask(self._task_stack[-1])
 
78
        else:
 
79
            t = progress.ProgressTask()
 
80
        self._task_stack.append(t)
 
81
        return t
 
82
 
 
83
    def progress_finished(self, task):
 
84
        if task != self._task_stack[-1]:
 
85
            raise AssertionError()
 
86
        del self._task_stack[-1]
77
87
 
78
88
    def clear_term(self):
79
89
        """Prepare the terminal for output.
167
177
    def get_password(self, prompt='', **kwargs):
168
178
        return None
169
179
 
170
 
    def nested_progress_bar(self):
171
 
        if self._progress_bar_stack is None:
172
 
            self._progress_bar_stack = progress.ProgressBarStack(
173
 
                klass=progress.DummyProgress)
174
 
        return self._progress_bar_stack.get_nested()
175
 
 
176
180
    def clear_term(self):
177
181
        pass
178
182
 
179
183
    def recommend_upgrade(self, *args):
180
184
        pass
181
185
 
 
186
    def show_progress(self, task):
 
187
        pass
 
188
 
 
189
    def progress_finished(self, task):
 
190
        pass
182
191
 
183
192
def clear_decorator(func, *args, **kwargs):
184
193
    """Decorator that clears the term"""