/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 breezy/progress.py

  • Committer: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Progress indicators.
18
18
 
19
 
The usual way to use this is via bzrlib.ui.ui_factory.nested_progress_bar which
 
19
The usual way to use this is via breezy.ui.ui_factory.nested_progress_bar which
20
20
will manage a conceptual stack of nested activities.
21
21
"""
22
22
 
23
 
from __future__ import absolute_import
24
 
 
25
23
import time
26
24
import os
27
25
 
66
64
        synchronously.
67
65
 
68
66
    :ivar show_transport_activity: If true (default), transport activity
69
 
        will be shown when this task is drawn.  Disable it if you're sure 
 
67
        will be shown when this task is drawn.  Disable it if you're sure
70
68
        that only irrelevant or uninteresting transport activity can occur
71
69
        during this task.
72
70
    """
78
76
 
79
77
        :param progress_view: ProgressView to display this ProgressTask.
80
78
 
81
 
        :param ui_factory: The UI factory that will display updates; 
 
79
        :param ui_factory: The UI factory that will display updates;
82
80
            deprecated in favor of passing progress_view directly.
83
81
 
84
82
        Normally you should not call this directly but rather through
132
130
 
133
131
    def make_sub_task(self):
134
132
        return ProgressTask(self, ui_factory=self.ui_factory,
135
 
            progress_view=self.progress_view)
 
133
                            progress_view=self.progress_view)
136
134
 
137
135
    def _overall_completion_fraction(self, child_fraction=0.0):
138
136
        """Return fractional completion of this task and its parents
139
137
 
140
138
        Returns None if no completion can be computed."""
141
139
        if self.current_cnt is not None and self.total_cnt:
142
 
            own_fraction = (float(self.current_cnt) + child_fraction) / self.total_cnt
 
140
            own_fraction = (float(self.current_cnt) +
 
141
                            child_fraction) / self.total_cnt
143
142
        else:
144
143
            # if this task has no estimation, it just passes on directly
145
144
            # whatever the child has measured...
164
163
        else:
165
164
            self.ui_factory.clear_term()
166
165
 
 
166
    def __enter__(self):
 
167
        return self
 
168
 
 
169
    def __exit__(self, exc_type, exc_val, exc_tb):
 
170
        self.finished()
 
171
        return False
 
172
 
167
173
 
168
174
class DummyProgress(object):
169
175
    """Progress-bar standin that does nothing.
194
200
    if delt is None:
195
201
        return "-:--:--"
196
202
    delt = int(round(delt))
197
 
    return '%d:%02d:%02d' % (delt/3600,
198
 
                             (delt/60) % 60,
 
203
    return '%d:%02d:%02d' % (delt / 3600,
 
204
                             (delt / 60) % 60,
199
205
                             delt % 60)
200
206
 
201
207
 
202
 
def get_eta(start_time, current, total, enough_samples=3, last_updates=None, n_recent=10):
 
208
def get_eta(start_time, current, total, enough_samples=3, last_updates=None,
 
209
            n_recent=10):
203
210
    if start_time is None:
204
211
        return None
205
212
 
233
240
 
234
241
class ProgressPhase(object):
235
242
    """Update progress object with the current phase"""
 
243
 
236
244
    def __init__(self, message, total, pb):
237
245
        object.__init__(self)
238
246
        self.pb = pb