~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-01-23 18:14:16 UTC
  • mfrom: (3948.2.8 progress)
  • Revision ID: pqm@pqm.ubuntu.com-20090123181416-tku4gdtorboy6d0y
(mbp) further progress bar fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
81
81
        self._task_stack.append(t)
82
82
        return t
83
83
 
84
 
    def progress_finished(self, task):
85
 
        if task != self._task_stack[-1]:
86
 
            warnings.warn("%r is not currently active" % (task,))
 
84
    def _progress_finished(self, task):
 
85
        """Called by the ProgressTask when it finishes"""
 
86
        if not self._task_stack:
 
87
            warnings.warn("%r finished but nothing is active"
 
88
                % (task,))
 
89
        elif task != self._task_stack[-1]:
 
90
            warnings.warn("%r is not the active task %r" 
 
91
                % (task, self._task_stack[-1]))
87
92
        else:
88
93
            del self._task_stack[-1]
 
94
        if not self._task_stack:
 
95
            self._progress_all_finished()
 
96
 
 
97
    def _progress_all_finished(self):
 
98
        """Called when the top-level progress task finished"""
 
99
        pass
 
100
 
 
101
    def _progress_updated(self, task):
 
102
        """Called by the ProgressTask when it changes.
 
103
        
 
104
        Should be specialized to draw the progress.
 
105
        """
 
106
        pass
89
107
 
90
108
    def clear_term(self):
91
109
        """Prepare the terminal for output.
92
110
 
93
111
        This will, for example, clear text progress bars, and leave the
94
 
        cursor at the leftmost position."""
95
 
        raise NotImplementedError(self.clear_term)
 
112
        cursor at the leftmost position.
 
113
        """
 
114
        pass
96
115
 
97
116
    def get_boolean(self, prompt):
98
117
        """Get a boolean question answered from the user. 
178
197
        """Write an already-formatted message."""
179
198
        self.stdout.write(msg + '\n')
180
199
 
181
 
    def clear_term(self):
182
 
        pass
183
 
 
184
 
    def show_progress(self, task):
185
 
        pass
186
 
 
187
 
    def progress_finished(self, task):
188
 
        pass
189
 
 
190
200
 
191
201
class SilentUIFactory(CLIUIFactory):
192
202
    """A UI Factory which never prints anything.