summaryrefslogtreecommitdiff
blob: 08ba2c01dcb94ed47d1a50ddf372e6f285b826ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

import time
class ProgressHandler(object):
	def __init__(self):
		self.curval = 0
		self.maxval = 0
		self._last_update = 0
		self.min_latency = 0.2

	def onProgress(self, maxval, curval):
		self.maxval = maxval
		self.curval = curval
		cur_time = time.time()
		if cur_time - self._last_update >= self.min_latency:
			self._last_update = cur_time
			self.display()

	def display(self):
		raise NotImplementedError(self)