~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: Martin Pool
  • Date: 2008-12-16 03:30:52 UTC
  • mto: (3882.7.11 progress)
  • mto: This revision was merged to the branch mainline in revision 3940.
  • Revision ID: mbp@sourcefrog.net-20081216033052-crrxy0eo3njhtidl
ProgressTask holds a reference to the ui that displays it

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
    and it will in turn update the display, if one is present.
68
68
    """
69
69
 
70
 
    def __init__(self, parent_task=None):
 
70
    def __init__(self, parent_task=None, ui_factory=None):
71
71
        self._parent_task = parent_task
72
72
        self._last_update = 0
73
73
        self.total_cnt = None
74
74
        self.current_cnt = None
75
75
        self.msg = ''
 
76
        self.ui_factory = ui_factory
76
77
 
77
78
    def update(self, msg, current_cnt=None, total_cnt=None):
78
79
        self.msg = msg
79
80
        self.current_cnt = current_cnt
80
81
        if total_cnt:
81
82
            self.total_cnt = total_cnt
82
 
        ui.ui_factory.show_progress(self)
 
83
        self.ui_factory.show_progress(self)
83
84
 
84
85
    def finished(self):
85
 
        ui.ui_factory.progress_finished(self)
 
86
        self.ui_factory.progress_finished(self)
86
87
 
87
88
    def make_sub_task(self):
88
 
        return ProgressTask(parent_task=self)
 
89
        return ProgressTask(parent_task=self, self.ui_factory)
89
90
 
90
91
    def _overall_completion_fraction(self, child_fraction=0.0):
91
92
        """Return fractional completion of this task and its parents
105
106
    def note(self, fmt_string, *args, **kwargs):
106
107
        """Record a note without disrupting the progress bar."""
107
108
        # XXX: shouldn't be here; put it in mutter or the ui instead
108
 
        ui.ui_factory.clear_term()
 
109
        self.ui_factory.clear_term()
109
110
        trace.note(fmt_string % args)
110
111
 
111
112
    def clear(self):
112
113
        # XXX: shouldn't be here; put it in mutter or the ui instead
113
 
        ui.ui_factory.clear_term()
 
114
        self.ui_factory.clear_term()
114
115
 
115
116
 
116
117
def ProgressBar(to_file=None, **kwargs):