Show More
@@ -229,39 +229,42 b' class progbar(object):' | |||
|
229 | 229 | |
|
230 | 230 | def progress(self, topic, pos, item='', unit='', total=None): |
|
231 | 231 | now = time.time() |
|
232 | if pos is None: | |
|
233 | self.starttimes.pop(topic, None) | |
|
234 |
self.start |
|
|
235 |
self. |
|
|
236 | # reset the progress bar if this is the outermost topic | |
|
237 | if self.topics and self.topics[0] == topic and self.printed: | |
|
238 | self.complete() | |
|
239 |
self. |
|
|
240 | # truncate the list of topics assuming all topics within | |
|
241 | # this one are also closed | |
|
242 | if topic in self.topics: | |
|
243 |
|
|
|
244 | # reset the last topic to the one we just unwound to, | |
|
245 | # so that higher-level topics will be stickier than | |
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
|
249 | else: | |
|
250 |
|
|
|
251 | else: | |
|
252 | if topic not in self.topics: | |
|
253 | self.starttimes[topic] = now | |
|
254 |
self.start |
|
|
255 |
self. |
|
|
256 | self.topicstates[topic] = pos, item, unit, total | |
|
257 | if now - self.lastprint >= self.refresh and self.topics: | |
|
258 | if (self.lasttopic is None # first time we printed | |
|
259 | # not a topic change | |
|
260 |
|
|
|
261 | # it's been long enough we should print anyway | |
|
262 | or now - self.lastprint >= self.changedelay): | |
|
263 |
self.lastprint = |
|
|
264 | self.show(now, topic, *self.topicstates[topic]) | |
|
232 | try: | |
|
233 | if pos is None: | |
|
234 | self.starttimes.pop(topic, None) | |
|
235 | self.startvals.pop(topic, None) | |
|
236 | self.topicstates.pop(topic, None) | |
|
237 | # reset the progress bar if this is the outermost topic | |
|
238 | if self.topics and self.topics[0] == topic and self.printed: | |
|
239 | self.complete() | |
|
240 | self.resetstate() | |
|
241 | # truncate the list of topics assuming all topics within | |
|
242 | # this one are also closed | |
|
243 | if topic in self.topics: | |
|
244 | self.topics = self.topics[:self.topics.index(topic)] | |
|
245 | # reset the last topic to the one we just unwound to, | |
|
246 | # so that higher-level topics will be stickier than | |
|
247 | # lower-level topics | |
|
248 | if self.topics: | |
|
249 | self.lasttopic = self.topics[-1] | |
|
250 | else: | |
|
251 | self.lasttopic = None | |
|
252 | else: | |
|
253 | if topic not in self.topics: | |
|
254 | self.starttimes[topic] = now | |
|
255 | self.startvals[topic] = pos | |
|
256 | self.topics.append(topic) | |
|
257 | self.topicstates[topic] = pos, item, unit, total | |
|
258 | if now - self.lastprint >= self.refresh and self.topics: | |
|
259 | if (self.lasttopic is None # first time we printed | |
|
260 | # not a topic change | |
|
261 | or topic == self.lasttopic | |
|
262 | # it's been long enough we should print anyway | |
|
263 | or now - self.lastprint >= self.changedelay): | |
|
264 | self.lastprint = now | |
|
265 | self.show(now, topic, *self.topicstates[topic]) | |
|
266 | finally: | |
|
267 | pass | |
|
265 | 268 | |
|
266 | 269 | _singleton = None |
|
267 | 270 |
General Comments 0
You need to be logged in to leave comments.
Login now