fixed some reading/writing problems
svn: r723
This commit is contained in:
parent
f579cd3065
commit
93b695c928
@ -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"]))
|
||||
|
@ -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('<?xml version="1.0" encoding="iso-8859-1"?>\n')
|
||||
self.g.write('<!DOCTYPE self.db SYSTEM "gramps.dtd" []>\n')
|
||||
@ -156,7 +156,9 @@ class XmlWriter:
|
||||
self.g.write(" <created date=\"%s %s %s\"" % (date[2],string.upper(date[1]),date[4]))
|
||||
self.g.write(" version=\"" + const.version + "\"")
|
||||
self.g.write(" people=\"%d\"" % (len(self.db.getPersonMap().values())))
|
||||
self.g.write(" families=\"%d\"/>\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(" <researcher>\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(" <sources>\n")
|
||||
for source in sourceList:
|
||||
if self.callback and count % delta == 0:
|
||||
self.callback(float(count)/float(total))
|
||||
count = count + 1
|
||||
self.g.write(" <source id=\"" + source.getId() + "\">\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(" <places>\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(" </places>\n")
|
||||
|
||||
@ -458,7 +465,7 @@ class XmlWriter:
|
||||
|
||||
self.g.write('%s<dateval val="%s"%s%s/>\n' % (sp,dstr,pref,calstr))
|
||||
else:
|
||||
self.g.write('%s<datestr val="%s"/>\n' %(sp,fix(date.getText())))
|
||||
self.g.write('%s<datestr val="%s"/>\n' %(sp,self.fix(date.getText())))
|
||||
|
||||
def write_force_line(self,label,value,indent=1):
|
||||
if value != None:
|
||||
|
@ -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("")
|
||||
|
Loading…
Reference in New Issue
Block a user