##// END OF EJS Templates
progress: move update check into helper method
Solomon Matthews -
r23907:63c7783a default
parent child Browse files
Show More
@@ -228,6 +228,17 b' class progbar(object):'
228 228 return _('%d %s/sec') % (delta / elapsed, unit)
229 229 return ''
230 230
231 def _oktoprint(self, now):
232 '''Check if conditions are met to print - e.g. changedelay elapsed'''
233 if (self.lasttopic is None # first time we printed
234 # not a topic change
235 or self.curtopic == self.lasttopic
236 # it's been long enough we should print anyway
237 or now - self.lastprint >= self.changedelay):
238 return True
239 else:
240 return False
241
231 242 def progress(self, topic, pos, item='', unit='', total=None):
232 243 now = time.time()
233 244 try:
@@ -258,11 +269,7 b' class progbar(object):'
258 269 self.topicstates[topic] = pos, item, unit, total
259 270 self.curtopic = topic
260 271 if now - self.lastprint >= self.refresh and self.topics:
261 if (self.lasttopic is None # first time we printed
262 # not a topic change
263 or topic == self.lasttopic
264 # it's been long enough we should print anyway
265 or now - self.lastprint >= self.changedelay):
272 if self._oktoprint(now):
266 273 self.lastprint = now
267 274 self.show(now, topic, *self.topicstates[topic])
268 275 finally:
General Comments 0
You need to be logged in to leave comments. Login now