/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: Martin Pool
  • Date: 2009-06-19 07:28:41 UTC
  • mto: This revision was merged to the branch mainline in revision 4558.
  • Revision ID: mbp@sourcefrog.net-20090619072841-ai67v7p1cy824mq2
ProgressTask now talks to ProgressView; easier to test

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
    will not necessarily respect all these fields.
73
73
    """
74
74
 
75
 
    def __init__(self, parent_task=None, ui_factory=None):
 
75
    def __init__(self, parent_task=None, ui_factory=None, progress_view=None):
76
76
        """Construct a new progress task.
77
77
 
 
78
        :param parent_task: Enclosing ProgressTask or None.
 
79
 
 
80
        :param progress_view: ProgressView to display this ProgressTask.
 
81
 
 
82
        :param ui_factory: The UI factory that will display updates; 
 
83
            deprecated in favor of passing progress_view directly.
 
84
 
78
85
        Normally you should not call this directly but rather through
79
86
        `ui_factory.nested_progress_bar`.
80
87
        """
83
90
        self.total_cnt = None
84
91
        self.current_cnt = None
85
92
        self.msg = ''
 
93
        # TODO: deprecate passing ui_factory
86
94
        self.ui_factory = ui_factory
 
95
        self.progress_view = progress_view
87
96
        self.show_pct = False
88
97
        self.show_spinner = True
89
98
        self.show_eta = False,
102
111
        self.current_cnt = current_cnt
103
112
        if total_cnt:
104
113
            self.total_cnt = total_cnt
105
 
        self.ui_factory._progress_updated(self)
 
114
        if self.progress_view:
 
115
            self.progress_view.show_progress(self)
 
116
        else:
 
117
            self.ui_factory._progress_updated(self)
106
118
 
107
119
    def tick(self):
108
120
        self.update(self.msg)
109
121
 
110
122
    def finished(self):
111
 
        self.ui_factory._progress_finished(self)
 
123
        if self.progress_view:
 
124
            self.progress_view.task_finished(self)
 
125
        else:
 
126
            self.ui_factory._progress_finished(self)
112
127
 
113
128
    def make_sub_task(self):
114
 
        return ProgressTask(self, self.ui_factory)
 
129
        return ProgressTask(self, ui_factory=self.ui_factory,
 
130
            progress_view=self.progress_view)
115
131
 
116
132
    def _overall_completion_fraction(self, child_fraction=0.0):
117
133
        """Return fractional completion of this task and its parents
140
156
 
141
157
    def clear(self):
142
158
        # XXX: shouldn't be here; put it in mutter or the ui instead
143
 
        self.ui_factory.clear_term()
 
159
        if self.progress_view:
 
160
            self.progress_view.clear()
 
161
        else:
 
162
            self.ui_factory.clear_term()
144
163
 
145
164
 
146
165
@deprecated_function(deprecated_in((1, 16, 0)))