From: Kees B. <kee...@xs...> - 2006-01-17 20:45:28
|
Hi, Importing a GEDCOM is really slow. Mainly it is because the progressbar is updated after each input line. Here is a patch that updates the progress bar fewer times. (I'm assuming the mailing list doesn't eat attachments. Oh, and if there another way to communicate patch suggestions, please let me know.) diff -ru -x CVS gramps2.orig/src/GrampsDb/_ReadGedcom.py gramps2/src/GrampsDb/_ReadGedcom.py --- gramps2.orig/src/GrampsDb/_ReadGedcom.py 2006-01-13 03:38:25.000000000 +0100 +++ gramps2/src/GrampsDb/_ReadGedcom.py 2006-01-17 21:35:15.000000000 +0100 @@ -327,7 +327,7 @@ BadFile = "Not a GEDCOM file" def __init__(self, dbase, filename, window, codeset, note_map, lines): - self.maxlines = float(lines) + self.maxlines = lines self.dp = GedcomDateParser() self.db = dbase self.person = None @@ -407,7 +407,7 @@ self.error_count = 0 amap = Utils.personalConstantAttributes - self.current = 0.0 + self.current = 0 self.oldval = 0.0 self.attrs = amap.values() @@ -499,12 +499,12 @@ def get_next(self): if self.backoff == 0: next_line = self.f.readline() - self.current += 1.0 + self.current += 1 - newval = self.current/self.maxlines + newval = (100*self.current)/self.maxlines if newval != self.oldval: - self.progressbar.set_fraction(min(newval,1.0)) - self.progressbar.set_text("%d%%" % int(newval*100)) + self.progressbar.set_fraction(min((float(newval)/100),1.0)) + self.progressbar.set_text("%d%%" % newval) self.oldval = newval while gtk.events_pending(): gtk.main_iteration() |