Improved XML formatting
svn: r265
This commit is contained in:
parent
8e8a3d3fb0
commit
abd0ee6ac1
@ -188,7 +188,11 @@ def on_sourceok_clicked(obj):
|
|||||||
current_source_ref.setComments(comments)
|
current_source_ref.setComments(comments)
|
||||||
|
|
||||||
if src_edit.update:
|
if src_edit.update:
|
||||||
src_edit.update.set_text(current_source_ref.getBase().getTitle())
|
if current_source_ref.getBase():
|
||||||
|
val = current_source_ref.getBase().getTitle()
|
||||||
|
else:
|
||||||
|
val = ""
|
||||||
|
src_edit.update.set_text(val)
|
||||||
|
|
||||||
utils.modified()
|
utils.modified()
|
||||||
utils.destroy_passed_object(obj)
|
utils.destroy_passed_object(obj)
|
||||||
|
@ -74,16 +74,16 @@ def writeNote(g,val,note,indent=0):
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def dump_event(g,event):
|
def dump_event(g,event,index=1):
|
||||||
if event:
|
if event:
|
||||||
dump_my_event(g,event.getName(),event)
|
dump_my_event(g,event.getName(),event,index)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def dump_my_event(g,name,event):
|
def dump_my_event(g,name,event,index=1):
|
||||||
if not event:
|
if not event:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -94,23 +94,24 @@ def dump_my_event(g,name,event):
|
|||||||
not date and not place and not description:
|
not date and not place and not description:
|
||||||
return
|
return
|
||||||
|
|
||||||
g.write(' <event type="%s" conf="%d" priv="%d">\n' % \
|
sp = " " * index
|
||||||
(fix(name),event.getConfidence(),event.getPrivacy()))
|
g.write('%s<event type="%s" conf="%d" priv="%d">\n' % \
|
||||||
write_line(g,"date",date,3)
|
(sp,fix(name),event.getConfidence(),event.getPrivacy()))
|
||||||
write_line(g,"place",place,3)
|
write_line(g,"date",date,index+1)
|
||||||
write_line(g,"description",description,3)
|
write_line(g,"place",place,index+1)
|
||||||
|
write_line(g,"description",description,index+1)
|
||||||
if event.getNote() != "":
|
if event.getNote() != "":
|
||||||
writeNote(g,"note",event.getNote(),3)
|
writeNote(g,"note",event.getNote(),index+1)
|
||||||
|
|
||||||
dump_source_ref(g,event.getSourceRef())
|
dump_source_ref(g,event.getSourceRef(),index+1)
|
||||||
g.write(" </event>\n")
|
g.write("%s</event>\n" % sp)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def dump_source_ref(g,source_ref):
|
def dump_source_ref(g,source_ref,index=1):
|
||||||
if source_ref:
|
if source_ref:
|
||||||
source = source_ref.getBase()
|
source = source_ref.getBase()
|
||||||
if source:
|
if source:
|
||||||
@ -118,46 +119,48 @@ def dump_source_ref(g,source_ref):
|
|||||||
c = source_ref.getComments()
|
c = source_ref.getComments()
|
||||||
t = source_ref.getText()
|
t = source_ref.getText()
|
||||||
d = source_ref.getDate().getSaveDate()
|
d = source_ref.getDate().getSaveDate()
|
||||||
|
g.write(" " * index)
|
||||||
if p == "" and c == "" and t == "" and d == "":
|
if p == "" and c == "" and t == "" and d == "":
|
||||||
g.write("<sourceref ref=\"%s\"/>\n" % source.getId())
|
g.write("<sourceref ref=\"%s\"/>\n" % source.getId())
|
||||||
else:
|
else:
|
||||||
g.write("<sourceref ref=\"%s\">\n" % source.getId())
|
g.write("<sourceref ref=\"%s\">\n" % source.getId())
|
||||||
write_line(g,"spage",p)
|
write_line(g,"spage",p,index+1)
|
||||||
writeNote(g,"scomments",c)
|
writeNote(g,"scomments",c,index+1)
|
||||||
writeNote(g,"stext",t)
|
writeNote(g,"stext",t,index+1)
|
||||||
write_line(g,"sdate",d)
|
write_line(g,"sdate",d,index+1)
|
||||||
g.write("</sourceref>\n")
|
g.write("%s</sourceref>\n" % (" " * index))
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def write_ref(g,label,person):
|
def write_ref(g,label,person,index=1):
|
||||||
if person:
|
if person:
|
||||||
g.write('<%s ref="%s"/>\n' % (label,person.getId()))
|
g.write('%s<%s ref="%s"/>\n' % (" "*index,label,person.getId()))
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def write_id(g,label,person):
|
def write_id(g,label,person,index=1):
|
||||||
if person:
|
if person:
|
||||||
g.write(' <%s id="%s">\n' % (label,person.getId()))
|
g.write('%s<%s id="%s">\n' % (" "*index,label,person.getId()))
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def write_family_id(g,family):
|
def write_family_id(g,family,index=1):
|
||||||
if family:
|
if family:
|
||||||
rel = family.getRelationship()
|
rel = family.getRelationship()
|
||||||
|
sp = " " * index
|
||||||
if rel != "":
|
if rel != "":
|
||||||
g.write('<family id="%s" type="%s">\n' % (family.getId(),rel))
|
g.write('%s<family id="%s" type="%s">\n' % (sp,family.getId(),rel))
|
||||||
else:
|
else:
|
||||||
g.write('<family id="%s">\n' % family.getId())
|
g.write('%s<family id="%s">\n' % (sp,family.getId()))
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -173,18 +176,28 @@ def write_line(g,label,value,indent=1):
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
def dump_name(g,label,name):
|
def write_force_line(g,label,value,indent=1):
|
||||||
g.write(' <%s conf="%s" priv="%s">\n' % \
|
if value != None:
|
||||||
(label,name.getConfidence(),name.getPrivacy()))
|
g.write('%s<%s>%s</%s>\n' % (' '*indent,label,fix(value),label))
|
||||||
write_line(g,"first",name.getFirstName(),3)
|
|
||||||
write_line(g,"last",name.getSurname(),3)
|
|
||||||
write_line(g,"suffix",name.getSuffix(),3)
|
|
||||||
write_line(g,"title",name.getTitle(),3)
|
|
||||||
if name.getNote() != "":
|
|
||||||
writeNote(g,"note",name.getNote())
|
|
||||||
dump_source_ref(g,name.getSourceRef())
|
|
||||||
|
|
||||||
g.write(' </%s>\n' % label)
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def dump_name(g,label,name,index=1):
|
||||||
|
sp = " "*index
|
||||||
|
g.write('%s<%s conf="%s" priv="%s">\n' % \
|
||||||
|
(sp,label,name.getConfidence(),name.getPrivacy()))
|
||||||
|
write_line(g,"first",name.getFirstName(),index+1)
|
||||||
|
write_line(g,"last",name.getSurname(),index+1)
|
||||||
|
write_line(g,"suffix",name.getSuffix(),index+1)
|
||||||
|
write_line(g,"title",name.getTitle(),index+1)
|
||||||
|
if name.getNote() != "":
|
||||||
|
writeNote(g,"note",name.getNote(),index+1)
|
||||||
|
dump_source_ref(g,name.getSourceRef(),index+1)
|
||||||
|
|
||||||
|
g.write('%s</%s>\n' % (sp,label))
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -247,28 +260,28 @@ def exportData(database, filename, callback):
|
|||||||
callback(float(count)/float(total))
|
callback(float(count)/float(total))
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
|
||||||
write_id(g,"person",person)
|
write_id(g,"person",person,2)
|
||||||
if person.getGender() == Person.male:
|
if person.getGender() == Person.male:
|
||||||
write_line(g,"gender","M",2)
|
write_line(g,"gender","M",3)
|
||||||
else:
|
else:
|
||||||
write_line(g,"gender","F",2)
|
write_line(g,"gender","F",3)
|
||||||
dump_name(g,"name",person.getPrimaryName())
|
dump_name(g,"name",person.getPrimaryName(),3)
|
||||||
for name in person.getAlternateNames():
|
for name in person.getAlternateNames():
|
||||||
dump_name(g,"aka",name)
|
dump_name(g,"aka",name,3)
|
||||||
|
|
||||||
write_line(g,"uid",person.getPafUid())
|
write_line(g,"uid",person.getPafUid(),3)
|
||||||
write_line(g,"nick",person.getNickName())
|
write_line(g,"nick",person.getNickName(),3)
|
||||||
dump_my_event(g,"Birth",person.getBirth())
|
dump_my_event(g,"Birth",person.getBirth(),3)
|
||||||
dump_my_event(g,"Death",person.getDeath())
|
dump_my_event(g,"Death",person.getDeath(),3)
|
||||||
for event in person.getEventList():
|
for event in person.getEventList():
|
||||||
dump_event(g,event)
|
dump_event(g,event,3)
|
||||||
|
|
||||||
for photo in person.getPhotoList():
|
for photo in person.getPhotoList():
|
||||||
path = photo.getPath()
|
path = photo.getPath()
|
||||||
if os.path.dirname(path) == fileroot:
|
if os.path.dirname(path) == fileroot:
|
||||||
path = os.path.basename(path)
|
path = os.path.basename(path)
|
||||||
g.write("<img src=\"" + fix(path) + "\"")
|
g.write(' <img src="%s"' % fix(path) )
|
||||||
g.write(" descrip=\"" + fix(photo.getDescription()) + "\"")
|
g.write(' descrip="%s"' % fix(photo.getDescription()))
|
||||||
proplist = photo.getPropertyList()
|
proplist = photo.getPropertyList()
|
||||||
if proplist:
|
if proplist:
|
||||||
for key in proplist.keys():
|
for key in proplist.keys():
|
||||||
@ -276,136 +289,139 @@ def exportData(database, filename, callback):
|
|||||||
g.write("/>\n")
|
g.write("/>\n")
|
||||||
|
|
||||||
if len(person.getAddressList()) > 0:
|
if len(person.getAddressList()) > 0:
|
||||||
g.write("<addresses>\n")
|
g.write(" <addresses>\n")
|
||||||
for address in person.getAddressList():
|
for address in person.getAddressList():
|
||||||
g.write('<address conf="%d" priv="%d">\n' % \
|
g.write(' <address conf="%d" priv="%d">\n' % \
|
||||||
(address.getConfidence(), address.getPrivacy()))
|
(address.getConfidence(), address.getPrivacy()))
|
||||||
write_line(g,"date",address.getDateObj().getSaveDate())
|
write_line(g,"date",address.getDateObj().getSaveDate(),5)
|
||||||
write_line(g,"street",address.getStreet())
|
write_line(g,"street",address.getStreet(),5)
|
||||||
write_line(g,"city",address.getCity())
|
write_line(g,"city",address.getCity(),5)
|
||||||
write_line(g,"state",address.getState())
|
write_line(g,"state",address.getState(),5)
|
||||||
write_line(g,"country",address.getCountry())
|
write_line(g,"country",address.getCountry(),5)
|
||||||
write_line(g,"postal",address.getPostal())
|
write_line(g,"postal",address.getPostal(),5)
|
||||||
if address.getNote() != "":
|
if address.getNote() != "":
|
||||||
writeNote(g,"note",address.getNote())
|
writeNote(g,"note",address.getNote(),5)
|
||||||
dump_source_ref(g,address.getSourceRef())
|
dump_source_ref(g,address.getSourceRef(),5)
|
||||||
g.write('</address>\n')
|
g.write(' </address>\n')
|
||||||
g.write('</addresses>\n')
|
g.write(' </addresses>\n')
|
||||||
|
|
||||||
if len(person.getAttributeList()) > 0:
|
if len(person.getAttributeList()) > 0:
|
||||||
g.write("<attributes>\n")
|
g.write(" <attributes>\n")
|
||||||
for attr in person.getAttributeList():
|
for attr in person.getAttributeList():
|
||||||
if attr.getSourceRef() or attr.getNote():
|
if attr.getSourceRef() or attr.getNote():
|
||||||
g.write('<attribute conf="%d" priv="%d">\n' % \
|
g.write(' <attribute conf="%d" priv="%d">\n' % \
|
||||||
(attr.getConfidence(),attr.getPrivacy()))
|
(attr.getConfidence(),attr.getPrivacy()))
|
||||||
|
|
||||||
write_line(g,"attr_type",attr.getType())
|
write_line(g,"attr_type",attr.getType(),5)
|
||||||
write_line(g,"attr_value",attr.getValue())
|
write_line(g,"attr_value",attr.getValue(),5)
|
||||||
dump_source_ref(g,attr.getSourceRef())
|
dump_source_ref(g,attr.getSourceRef(),5)
|
||||||
writeNote(g,"note",attr.getNote())
|
writeNote(g,"note",attr.getNote(),5)
|
||||||
g.write('</attribute>\n')
|
g.write(' </attribute>\n')
|
||||||
else:
|
else:
|
||||||
g.write('<attribute type="%s">' % attr.getType())
|
g.write(' <attribute type="%s">' % attr.getType())
|
||||||
g.write(fix(attr.getValue()))
|
g.write(fix(attr.getValue()))
|
||||||
g.write('</attribute>\n')
|
g.write('</attribute>\n')
|
||||||
g.write('</attributes>\n')
|
g.write(' </attributes>\n')
|
||||||
|
|
||||||
if len(person.getUrlList()) > 0:
|
if len(person.getUrlList()) > 0:
|
||||||
g.write("<urls>\n")
|
g.write(" <urls>\n")
|
||||||
for url in person.getUrlList():
|
for url in person.getUrlList():
|
||||||
g.write('<url priv="%d" href="%s"' % (url.getPrivacy(),url.get_path()))
|
g.write(' <url priv="%d" href="%s"' % \
|
||||||
|
(url.getPrivacy(),url.get_path()))
|
||||||
if url.get_description() != "":
|
if url.get_description() != "":
|
||||||
g.write(' description="' + url.get_description() + '"')
|
g.write(' description="' + url.get_description() + '"')
|
||||||
g.write('/>\n')
|
g.write('/>\n')
|
||||||
g.write('</urls>\n')
|
g.write(' </urls>\n')
|
||||||
|
|
||||||
write_ref(g,"childof",person.getMainFamily())
|
write_ref(g,"childof",person.getMainFamily(),3)
|
||||||
for alt in person.getAltFamilyList():
|
for alt in person.getAltFamilyList():
|
||||||
g.write("<childof ref=\"%s\" mrel=\"%s\" frel=\"%s\"/>\n" % \
|
g.write(" <childof ref=\"%s\" mrel=\"%s\" frel=\"%s\"/>\n" % \
|
||||||
(alt[0].getId(), alt[1], alt[2]))
|
(alt[0].getId(), alt[1], alt[2]))
|
||||||
|
|
||||||
for family in person.getFamilyList():
|
for family in person.getFamilyList():
|
||||||
write_ref(g,"parentin",family)
|
write_ref(g,"parentin",family,3)
|
||||||
|
|
||||||
writeNote(g,"note",person.getNote())
|
writeNote(g,"note",person.getNote(),3)
|
||||||
|
|
||||||
g.write("</person>\n")
|
g.write(" </person>\n")
|
||||||
g.write("</people>\n")
|
g.write(" </people>\n")
|
||||||
g.write("<families>\n")
|
|
||||||
|
|
||||||
for family in familyList:
|
if len(familyList) > 0:
|
||||||
if count % delta == 0:
|
g.write(" <families>\n")
|
||||||
callback(float(count)/float(total))
|
|
||||||
count = count + 1
|
|
||||||
|
|
||||||
write_family_id(g,family)
|
for family in familyList:
|
||||||
write_ref(g,"father",family.getFather())
|
if count % delta == 0:
|
||||||
write_ref(g,"mother",family.getMother())
|
callback(float(count)/float(total))
|
||||||
|
count = count + 1
|
||||||
|
|
||||||
dump_event(g,family.getMarriage())
|
write_family_id(g,family,2)
|
||||||
dump_event(g,family.getDivorce())
|
write_ref(g,"father",family.getFather(),3)
|
||||||
for event in family.getEventList():
|
write_ref(g,"mother",family.getMother(),3)
|
||||||
dump_event(g,event)
|
|
||||||
|
|
||||||
for photo in family.getPhotoList():
|
dump_event(g,family.getMarriage(),3)
|
||||||
path = photo.getPath()
|
dump_event(g,family.getDivorce(),3)
|
||||||
if os.path.dirname(path) == fileroot:
|
for event in family.getEventList():
|
||||||
path = os.path.basename(path)
|
dump_event(g,event,3)
|
||||||
g.write("<img src=\"" + fix(path) + "\"")
|
|
||||||
g.write(" descrip=\"" + fix(photo.getDescription()) + "\"")
|
|
||||||
proplist = photo.getPropertyList()
|
|
||||||
if proplist:
|
|
||||||
for key in proplist.keys():
|
|
||||||
g.write(' %s="%s"' % (key,proplist[key]))
|
|
||||||
g.write("/>\n")
|
|
||||||
|
|
||||||
if len(family.getChildList()) > 0:
|
for photo in family.getPhotoList():
|
||||||
g.write("<childlist>\n")
|
path = photo.getPath()
|
||||||
for person in family.getChildList():
|
if os.path.dirname(path) == fileroot:
|
||||||
write_ref(g,"child",person)
|
path = os.path.basename(path)
|
||||||
g.write("</childlist>\n")
|
g.write(" <img src=\"" + fix(path) + "\"")
|
||||||
if len(family.getAttributeList()) > 0:
|
g.write(" descrip=\"" + fix(photo.getDescription()) + "\"")
|
||||||
g.write("<attributes>\n")
|
proplist = photo.getPropertyList()
|
||||||
for attr in family.getAttributeList():
|
if proplist:
|
||||||
g.write('<attribute>\n')
|
for key in proplist.keys():
|
||||||
write_line(g,"attr_type",attr.getType())
|
g.write(' %s="%s"' % (key,proplist[key]))
|
||||||
write_line(g,"attr_value",attr.getValue())
|
g.write("/>\n")
|
||||||
dump_source_ref(g,attr.getSourceRef())
|
|
||||||
writeNote(g,"note",attr.getNote())
|
if len(family.getChildList()) > 0:
|
||||||
g.write('</attribute>\n')
|
g.write(" <childlist>\n")
|
||||||
g.write('</attributes>\n')
|
for person in family.getChildList():
|
||||||
writeNote(g,"note",family.getNote())
|
write_ref(g,"child",person,4)
|
||||||
g.write("</family>\n")
|
g.write(" </childlist>\n")
|
||||||
g.write("</families>\n")
|
if len(family.getAttributeList()) > 0:
|
||||||
|
g.write(" <attributes>\n")
|
||||||
|
for attr in family.getAttributeList():
|
||||||
|
g.write(' <attribute>\n')
|
||||||
|
write_line(g,"attr_type",attr.getType(),5)
|
||||||
|
write_line(g,"attr_value",attr.getValue(),5)
|
||||||
|
dump_source_ref(g,attr.getSourceRef(),5)
|
||||||
|
writeNote(g,"note",attr.getNote(),5)
|
||||||
|
g.write(' </attribute>\n')
|
||||||
|
g.write(' </attributes>\n')
|
||||||
|
writeNote(g,"note",family.getNote(),3)
|
||||||
|
g.write(" </family>\n")
|
||||||
|
g.write(" </families>\n")
|
||||||
|
|
||||||
if len(sourceList) > 0:
|
if len(sourceList) > 0:
|
||||||
g.write("<sources>\n")
|
g.write(" <sources>\n")
|
||||||
for source in sourceList:
|
for source in sourceList:
|
||||||
g.write("<source id=\"" + source.getId() + "\">\n")
|
g.write(" <source id=\"" + source.getId() + "\">\n")
|
||||||
write_line(g,"stitle",source.getTitle())
|
write_force_line(g,"stitle",source.getTitle(),3)
|
||||||
write_line(g,"sauthor",source.getAuthor())
|
write_line(g,"sauthor",source.getAuthor(),3)
|
||||||
write_line(g,"spubinfo",source.getPubInfo())
|
write_line(g,"spubinfo",source.getPubInfo(),3)
|
||||||
write_line(g,"scallno",source.getCallNumber())
|
write_line(g,"scallno",source.getCallNumber(),3)
|
||||||
if source.getNote() != "":
|
if source.getNote() != "":
|
||||||
writeNote(g,"note",source.getNote())
|
writeNote(g,"note",source.getNote(),3)
|
||||||
for photo in source.getPhotoList():
|
for photo in source.getPhotoList():
|
||||||
path = photo.getPath()
|
path = photo.getPath()
|
||||||
if os.path.dirname(path) == fileroot:
|
if os.path.dirname(path) == fileroot:
|
||||||
path = os.path.basename(path)
|
path = os.path.basename(path)
|
||||||
g.write("<img src=\"" + fix(path) + "\"")
|
g.write(" <img src=\"" + fix(path) + "\"")
|
||||||
g.write(" descrip=\"" + fix(photo.getDescription()) + "\"")
|
g.write(" descrip=\"" + fix(photo.getDescription()) + "\"")
|
||||||
proplist = photo.getPropertyList()
|
proplist = photo.getPropertyList()
|
||||||
if proplist:
|
if proplist:
|
||||||
for key in proplist.keys():
|
for key in proplist.keys():
|
||||||
g.write(' %s="%s"' % (key,proplist[key]))
|
g.write(' %s="%s"' % (key,proplist[key]))
|
||||||
g.write("</source>\n")
|
g.write(" </source>\n")
|
||||||
g.write("</sources>\n")
|
g.write(" </sources>\n")
|
||||||
|
|
||||||
if len(db.getBookmarks()) > 0:
|
if len(db.getBookmarks()) > 0:
|
||||||
g.write("<bookmarks>\n")
|
g.write(" <bookmarks>\n")
|
||||||
for person in db.getBookmarks():
|
for person in db.getBookmarks():
|
||||||
g.write("<bookmark ref=\"" + person.getId() + "\"/>\n")
|
g.write(' <bookmark ref="%s"/>\n' % person.getId())
|
||||||
g.write("</bookmarks>\n")
|
g.write(" </bookmarks>\n")
|
||||||
|
|
||||||
g.write("</database>\n")
|
g.write("</database>\n")
|
||||||
g.close()
|
g.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user