* src/GrampsDb/_ReadXML.py (GrampsParser): Use UpdateCallback.

* src/GrampsDb/_ReadGedcom.py (GedcomParser): Use UpdateCallback.
	(get_total): Add function, remove unneeded class.
	(UpdateCallback.update_real): Allow optional argument; 
	(UpdateCallback.set_total): Add method.


svn: r6618
This commit is contained in:
Alex Roitman
2006-05-11 06:16:45 +00:00
parent e9602a5eeb
commit 85c2ff5039
5 changed files with 38 additions and 61 deletions

View File

@@ -60,20 +60,21 @@ class UpdateCallback:
self.count = 0
self.oldval = 0
self.oldtime = 0
self.total = self.get_total()
self.interval = interval
else:
self.update = self.update_empty
def get_total(self):
assert False, "Needs to be defined in the derived class"
def set_total(self,total):
self.total = total
def update_empty(self):
pass
def update_real(self):
def update_real(self,count=None):
self.count += 1
newval = int(100.0*self.count/self.total)
if not count:
count = self.count
newval = int(100*count/self.total)
newtime = time.time()
time_has_come = self.interval and (newtime-self.oldtime>self.interval)
value_changed = newval!=self.oldval