Improved ANSEL support
svn: r452
This commit is contained in:
parent
c1968b6ad1
commit
18d221a7e7
@ -416,7 +416,9 @@ class GrampsParser(handler.ContentHandler):
|
||||
else:
|
||||
self.source_ref.confidence = self.conf
|
||||
self.source_ref.setBase(source)
|
||||
if self.event:
|
||||
if self.photo:
|
||||
self.photo.addSourceRef(self.source_ref)
|
||||
elif self.event:
|
||||
self.event.addSourceRef(self.source_ref)
|
||||
elif self.address:
|
||||
self.address.addSourceRef(self.source_ref)
|
||||
@ -426,8 +428,6 @@ class GrampsParser(handler.ContentHandler):
|
||||
self.attribute.addSourceRef(self.source_ref)
|
||||
elif self.placeobj:
|
||||
self.placeobj.addSourceRef(self.source_ref)
|
||||
else:
|
||||
print "Sorry, I'm lost"
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
#
|
||||
@ -808,6 +808,8 @@ class GrampsParser(handler.ContentHandler):
|
||||
|
||||
if self.address:
|
||||
self.address.setNote(note)
|
||||
elif self.photo:
|
||||
self.photo.setNote(note)
|
||||
elif self.attribute:
|
||||
self.attribute.setNote(note)
|
||||
elif self.name:
|
||||
|
@ -336,12 +336,13 @@ class Note:
|
||||
"""return the note contents"""
|
||||
return self.text
|
||||
|
||||
class Photo:
|
||||
class Photo(SourceNote):
|
||||
"""Containter for information about an image file, including location,
|
||||
description and privacy"""
|
||||
|
||||
def __init__(self,source=None):
|
||||
"""Create a new Photo object, copying from the source if provided"""
|
||||
SourceNote.__init__(self,source)
|
||||
self.attrlist = []
|
||||
if source:
|
||||
self.path = source.path
|
||||
|
@ -64,7 +64,7 @@ def fix(line):
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def writeNote(g,val,note,indent=0):
|
||||
def write_note(g,val,note,indent=0):
|
||||
if not note:
|
||||
return
|
||||
if indent != 0:
|
||||
@ -118,7 +118,7 @@ def dump_my_event(g,name,event,index=1):
|
||||
write_line(g,"cause",cause,index+1)
|
||||
write_line(g,"description",description,index+1)
|
||||
if event.getNote() != "":
|
||||
writeNote(g,"note",event.getNote(),index+1)
|
||||
write_note(g,"note",event.getNote(),index+1)
|
||||
|
||||
for s in event.getSourceRefList():
|
||||
dump_source_ref(g,s,index+1)
|
||||
@ -146,8 +146,8 @@ def dump_source_ref(g,source_ref,index=1):
|
||||
else:
|
||||
g.write('<sourceref ref="%s" conf="%d">\n' % (source.getId(),q))
|
||||
write_line(g,"spage",p,index+1)
|
||||
writeNote(g,"scomments",c,index+1)
|
||||
writeNote(g,"stext",t,index+1)
|
||||
write_note(g,"scomments",c,index+1)
|
||||
write_note(g,"stext",t,index+1)
|
||||
write_line(g,"sdate",d,index+1)
|
||||
g.write("%s</sourceref>\n" % (" " * index))
|
||||
|
||||
@ -214,7 +214,7 @@ def dump_name(g,label,name,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)
|
||||
write_note(g,"note",name.getNote(),index+1)
|
||||
for s in name.getSourceRefList():
|
||||
dump_source_ref(g,s,index+1)
|
||||
|
||||
@ -277,7 +277,7 @@ def write_attribute_list(g, list, indent=3):
|
||||
write_line(g,"attr_value",attr.getValue(),4)
|
||||
for s in attr.getSourceRefList():
|
||||
dump_source_ref(g,s,index+1)
|
||||
writeNote(g,"note",attr.getNote(),4)
|
||||
write_note(g,"note",attr.getNote(),4)
|
||||
g.write('%s</attribute>\n' % sp)
|
||||
else:
|
||||
g.write('%s<attribute type="%s">' % (sp,attr.getType()))
|
||||
@ -285,7 +285,8 @@ def write_attribute_list(g, list, indent=3):
|
||||
g.write('</attribute>\n')
|
||||
|
||||
|
||||
def write_photo_list(g,list):
|
||||
def write_photo_list(g,list,indent=3):
|
||||
sp = ' '*indent
|
||||
for photo in list:
|
||||
path = photo.getPath()
|
||||
if strip_photo:
|
||||
@ -295,15 +296,19 @@ def write_photo_list(g,list):
|
||||
if len(path) >= l:
|
||||
if fileroot == path[0:l]:
|
||||
path = path[l+1:]
|
||||
g.write(' <img src="%s"' % fix(path) )
|
||||
g.write('%s<img src="%s"' % (sp,fix(path)) )
|
||||
g.write(' description="%s"' % fix(photo.getDescription()))
|
||||
proplist = photo.getAttributeList()
|
||||
if len(proplist) == 0:
|
||||
srclist = photo.getSourceRefList()
|
||||
if len(proplist) == 0 and photo.getNote() == "" and len(srclist) == 0:
|
||||
g.write("/>\n")
|
||||
else:
|
||||
g.write(">\n")
|
||||
write_attribute_list(g,proplist,4)
|
||||
g.write(' </img>\n')
|
||||
write_attribute_list(g,proplist,indent+1)
|
||||
write_note(g,"note",photo.getNote(),indent+1)
|
||||
for s in photo.getSourceRefList():
|
||||
dump_source_ref(g,s,indent+1)
|
||||
g.write('%s</img>\n' % sp)
|
||||
|
||||
|
||||
def write_url_list(g, list):
|
||||
@ -332,7 +337,7 @@ def write_place_obj(g,place):
|
||||
write_photo_list(g,place.getPhotoList())
|
||||
write_url_list(g, place.getUrlList())
|
||||
if place.getNote() != "":
|
||||
writeNote(g,"note",place.getNote(),3)
|
||||
write_note(g,"note",place.getNote(),3)
|
||||
for s in place.getSourceRefList():
|
||||
dump_source_ref(g,s,index+1)
|
||||
g.write(" </placeobj>\n")
|
||||
@ -448,7 +453,7 @@ def write_xml_data(database, g, callback, sp):
|
||||
write_line(g,"country",address.getCountry(),4)
|
||||
write_line(g,"postal",address.getPostal(),4)
|
||||
if address.getNote() != "":
|
||||
writeNote(g,"note",address.getNote(),4)
|
||||
write_note(g,"note",address.getNote(),4)
|
||||
for s in address.getSourceRefList():
|
||||
dump_source_ref(g,s,index+1)
|
||||
g.write(' </address>\n')
|
||||
@ -472,7 +477,7 @@ def write_xml_data(database, g, callback, sp):
|
||||
for family in person.getFamilyList():
|
||||
write_ref(g,"parentin",family,3)
|
||||
|
||||
writeNote(g,"note",person.getNote(),3)
|
||||
write_note(g,"note",person.getNote(),3)
|
||||
|
||||
g.write(" </person>\n")
|
||||
g.write(" </people>\n")
|
||||
@ -501,7 +506,7 @@ def write_xml_data(database, g, callback, sp):
|
||||
for person in family.getChildList():
|
||||
write_ref(g,"child",person,3)
|
||||
write_attribute_list(g,family.getAttributeList())
|
||||
writeNote(g,"note",family.getNote(),3)
|
||||
write_note(g,"note",family.getNote(),3)
|
||||
g.write(" </family>\n")
|
||||
g.write(" </families>\n")
|
||||
|
||||
@ -514,7 +519,7 @@ def write_xml_data(database, g, callback, sp):
|
||||
write_line(g,"spubinfo",source.getPubInfo(),3)
|
||||
write_line(g,"scallno",source.getCallNumber(),3)
|
||||
if source.getNote() != "":
|
||||
writeNote(g,"note",source.getNote(),3)
|
||||
write_note(g,"note",source.getNote(),3)
|
||||
write_photo_list(g,source.getPhotoList())
|
||||
g.write(" </source>\n")
|
||||
g.write(" </sources>\n")
|
||||
|
@ -1,4 +1,4 @@
|
||||
#
|
||||
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000 Donald N. Allingham
|
||||
@ -63,12 +63,13 @@ _t1 = {
|
||||
}
|
||||
|
||||
_s0 = {
|
||||
0xCF : 0xDF, 0xA4 : 0xDE, 0xB4 : 0xFE, 0xA2 : 0xD8,
|
||||
0xCF : 0xDF, 0xA4 : 0xDE, 0xB4 : 0xFE, 0xA2 : 0xD8, 0xC0 : 0xB0,
|
||||
0xB3 : 0xF8, 0xA5 : 0xC6, 0xB5 : 0xE6, 0xBA : 0xF0 }
|
||||
|
||||
_t0 = {
|
||||
0xDF : chr(0xCF), 0xDE : chr(0xA4), 0xFE : chr(0xB4), 0xD8 : chr(0xA2),
|
||||
0xF8 : chr(0xB3), 0xC6 : chr(0xA5), 0xE6 : chr(0xB5), 0xBA : chr(0xF0) }
|
||||
0xF8 : chr(0xB3), 0xC6 : chr(0xA5), 0xE6 : chr(0xB5), 0xBA : chr(0xF0),
|
||||
0xB0 : chr(0xC0) }
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -134,11 +134,7 @@ def importData(database, filename):
|
||||
GnomeErrorDialog(_("%s could not be opened\n") % filename)
|
||||
return
|
||||
|
||||
import time
|
||||
t1 = time.time()
|
||||
g.parse_gedcom_file()
|
||||
t2 = time.time()
|
||||
print t2-t1
|
||||
|
||||
statusTop.get_widget("close").set_sensitive(1)
|
||||
|
||||
|
@ -525,7 +525,7 @@ def exportData(database, filename, pbar, fbar, sbar):
|
||||
if cnvtxt == latin_to_ansel:
|
||||
g.write("1 CHAR ANSEL\n");
|
||||
else:
|
||||
g.write("1 CHAR UNICODE\n");
|
||||
g.write("1 CHAR UTF-8\n");
|
||||
g.write("1 SUBM @SUBM@\n")
|
||||
g.write("1 FILE %s\n" % filename)
|
||||
g.write("1 GEDC\n")
|
||||
|
Loading…
Reference in New Issue
Block a user