From 93b695c928a1846f4da97a6f921ec8c678754711 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 24 Jan 2002 19:04:52 +0000 Subject: [PATCH] fixed some reading/writing problems svn: r723 --- gramps/src/GrampsParser.py | 19 ++++++++++++++++++- gramps/src/WriteXML.py | 15 +++++++++++---- gramps/src/gramps_main.py | 4 +++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/gramps/src/GrampsParser.py b/gramps/src/GrampsParser.py index a4feba3ac..c2c508131 100644 --- a/gramps/src/GrampsParser.py +++ b/gramps/src/GrampsParser.py @@ -153,6 +153,10 @@ class GrampsParser: self.placeobj = self.db.findPlaceNoMap(u2l(attrs['id'])) self.placeobj.set_title(u2l(attrs['title'])) self.locations = 0 + if self.num_places > 0: + if self.callback != None and self.count % self.increment == 0: + self.callback(float(self.count)/float(self.entries)) + self.count = self.count + 1 def start_location(self,attrs): loc = Location() @@ -337,6 +341,10 @@ class GrampsParser: self.placeobj.addSourceRef(self.source_ref) def start_source(self,attrs): + if self.num_srcs > 0: + if self.callback != None and self.count % self.increment == 0: + self.callback(float(self.count)/float(self.entries)) + self.count = self.count + 1 self.source = self.db.findSourceNoMap(u2l(attrs["id"])) def start_objref(self,attrs): @@ -455,7 +463,16 @@ class GrampsParser: d.set(u2l(attrs['val'])) def start_created(self,attrs): - self.entries = int(attrs["people"]) + int(attrs["families"]) + if attrs.has_key('sources'): + self.num_srcs = int(attrs['sources']) + else: + self.num_srcs = 0 + if attrs.has_key('places'): + self.num_places = int(attrs['places']) + else: + self.num_places = 0 + self.entries = int(attrs["people"]) + int(attrs["families"]) + \ + self.num_places + self.num_srcs def start_pos(self,attrs): self.person.position = (int(attrs["x"]), int(attrs["y"])) diff --git a/gramps/src/WriteXML.py b/gramps/src/WriteXML.py index f61d999e8..eba1369f9 100644 --- a/gramps/src/WriteXML.py +++ b/gramps/src/WriteXML.py @@ -147,7 +147,7 @@ class XmlWriter: objList = self.db.getObjectMap().values() objList.sort(sortById) - total = len(personList) + len(familyList) + total = len(personList) + len(familyList) + len(placeList) + len(sourceList) self.g.write('\n') self.g.write('\n') @@ -156,7 +156,9 @@ class XmlWriter: self.g.write(" \n" % len(self.db.getFamilyMap().values())) + self.g.write(" families=\"%d\"\n" % len(self.db.getFamilyMap().values())) + self.g.write(" sources=\"%d\"\n" % len(self.db.getSourceMap().values())) + self.g.write(" places=\"%d\"/>\n" % len(self.db.getPlaceMap().values())) self.g.write(" \n") self.write_line("resname",owner.getName(),3) self.write_line("resaddr",owner.getAddress(),3) @@ -176,7 +178,6 @@ class XmlWriter: self.g.write(' default="%s"' % person.getId()) self.g.write(">\n") - total = len(personList) + len(familyList) delta = max(int(total/50),1) count = 0 @@ -283,6 +284,9 @@ class XmlWriter: if len(sourceList) > 0: self.g.write(" \n") for source in sourceList: + if self.callback and count % delta == 0: + self.callback(float(count)/float(total)) + count = count + 1 self.g.write(" \n") self.write_force_line("stitle",source.getTitle(),3) self.write_line("sauthor",source.getAuthor(),3) @@ -297,6 +301,9 @@ class XmlWriter: if len(placeList) > 0: self.g.write(" \n") for place in placeList: + if self.callback and count % delta == 0: + self.callback(float(count)/float(total)) + count = count + 1 self.write_place_obj(place) self.g.write(" \n") @@ -458,7 +465,7 @@ class XmlWriter: self.g.write('%s\n' % (sp,dstr,pref,calstr)) else: - self.g.write('%s\n' %(sp,fix(date.getText()))) + self.g.write('%s\n' %(sp,self.fix(date.getText()))) def write_force_line(self,label,value,indent=1): if value != None: diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 4a5fb47ef..609aa58e5 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -567,7 +567,9 @@ def read_file(filename): statusbar.set_status(_("Loading %s ...") % filename) if load_database(filename) == 1: - name = os.path.basename(filename[:-1]) + if filename[-1] == '/': + filename = filename[:-1] + name = os.path.basename(filename) topWindow.set_title("%s - %s" % (name,_("GRAMPS"))) else: statusbar.set_status("")