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