* src/GrampsParser.py: handle new witness format in XML file

* src/WriteXML.py: handle new witness format in XML file
* src/dialog.glade: removed unused callbacks


svn: r2251
This commit is contained in:
Don Allingham 2003-10-14 03:13:52 +00:00
parent 96d3afd1a1
commit 5f0138f0d9
3 changed files with 56 additions and 25 deletions

View File

@ -61,6 +61,7 @@ class GrampsParser:
self.in_note = 0
self.in_stext = 0
self.in_scomments = 0
self.in_witness = 0
self.db = database
self.base = base
self.photo = None
@ -100,6 +101,7 @@ class GrampsParser:
self.func_list = [None]*50
self.func_index = 0
self.func = None
self.witness_comment = ""
self.func_map = {
"address" : (self.start_address, self.stop_address),
@ -116,7 +118,9 @@ class GrampsParser:
"childof" : (self.start_childof,None),
"city" : (None, self.stop_city),
"country" : (None, self.stop_country),
"comment" : (None, self.stop_comment),
"created" : (self.start_created, None),
"ref" : (None, self.stop_ref),
"database" : (None, None),
"date" : (None, self.stop_date),
"cause" : (None, self.stop_cause),
@ -267,9 +271,11 @@ class GrampsParser:
self.locations = self.locations + 1
def start_witness(self,attrs):
self.in_witness = 1
if attrs.has_key('ref'):
self.witness = RelLib.Witness(RelLib.Event.ID,attrs['ref'])
if attrs.has_key('name'):
print "name",attrs['name']
self.witness = RelLib.Witness(RelLib.Event.NAME,attrs['name'])
def start_coord(self,attrs):
@ -392,15 +398,16 @@ class GrampsParser:
self.person.FamilyList.append(self.db.findFamilyNoMap(attrs["ref"]))
def start_name(self,attrs):
self.name = RelLib.Name()
if attrs.has_key("type"):
self.name.setType(attrs["type"])
if attrs.has_key("conf"):
self.name.conf = int(attrs["conf"])
else:
self.name.conf = 2
if attrs.has_key("priv"):
self.name.private = int(attrs["priv"])
if not self.in_witness:
self.name = RelLib.Name()
if attrs.has_key("type"):
self.name.setType(attrs["type"])
if attrs.has_key("conf"):
self.name.conf = int(attrs["conf"])
else:
self.name.conf = 2
if attrs.has_key("priv"):
self.name.private = int(attrs["priv"])
def start_last(self,attrs):
if attrs.has_key('prefix'):
@ -581,9 +588,21 @@ class GrampsParser:
def stop_attribute(self,tag):
self.attribute = None
def stop_comment(self,tag):
if tag.strip():
self.witness_comment = tag
else:
self.witness_comment = ""
def stop_witness(self,tag):
self.witness.set_comment(tag)
if self.witness_comment:
self.witness.set_comment(self.witness_comment)
elif tag.strip():
self.witness.set_comment(tag)
else:
self.witness.set_comment("")
self.event.add_witness(self.witness)
self.in_witness = 0
def stop_attr_type(self,tag):
self.attribute.setType(tag)
@ -622,10 +641,16 @@ class GrampsParser:
self.event = None
def stop_name(self,tag):
if self.name.getType() == "":
self.name.setType("Birth Name")
self.person.setPrimaryName (self.name)
self.name = None
if self.in_witness:
self.witness = RelLib.Witness(RelLib.Event.NAME,tag)
else:
if self.name.getType() == "":
self.name.setType("Birth Name")
self.person.setPrimaryName (self.name)
self.name = None
def stop_ref(self,tag):
self.witness = RelLib.Witness(RelLib.Event.ID,tag)
def stop_place(self,tag):
if self.placeobj == None:

View File

@ -171,9 +171,9 @@ class XmlWriter:
total = person_len + family_len + place_len + source_len
self.g.write('<?xml version="1.0"?>\n')
self.g.write('<?xml version="1.0" encoding="UTF-8"?>\n')
self.g.write('<!DOCTYPE database SYSTEM "gramps.dtd" []>\n')
self.g.write("<database>\n")
self.g.write("<database xmlns=\"http://gramps.sourceforge.net/database\">\n")
self.g.write(" <header>\n")
self.g.write(" <created date=\"%s %s %s\"" % (date[2],string.upper(date[1]),date[4]))
self.g.write(" version=\"" + const.version + "\"")
@ -360,11 +360,11 @@ class XmlWriter:
self.g.write("</database>\n")
def fix(self,line):
l = string.strip(line)
l = string.replace(l,'&','&amp;')
l = string.replace(l,'>','&gt;')
l = string.replace(l,'<','&lt;')
return string.replace(l,'"','&quot;')
l = line.strip()
l = l.replace('&','&amp;')
l = l.replace('>','&gt;')
l = l.replace('<','&lt;')
return l.replace('"','&quot;')
def write_note(self,val,note,indent=0):
if not note:
@ -387,9 +387,17 @@ class XmlWriter:
sp = " "*index
com = self.fix(w.get_comment())
if w.get_type() == RelLib.Event.ID:
self.g.write('%s<witness ref="%s">%s</witness>\n' % (sp,w.get_value(),com))
self.g.write('%s<witness>\n' % sp)
self.g.write(' %s<ref>%s</ref>\n' % (sp,w.get_value()))
if com:
self.g.write(' %s<comment>%s</comment>\n' % (sp,com))
self.g.write('%s</witness>\n' % sp)
else:
self.g.write('%s<witness name="%s">%s</witness>\n' % (sp,w.get_value(),com))
self.g.write('%s<witness>\n' % sp)
self.g.write(' %s<name>%s</name>\n' % (sp,w.get_value()))
if com:
self.g.write(' %s<comment>%s</comment>\n' % (sp,com))
self.g.write('%s</witness>\n' % sp)
def dump_my_event(self,name,event,index=1):
if not event or event.is_empty():

View File

@ -3551,7 +3551,6 @@
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="cancel_clicked" last_modification_time="Tue, 18 Feb 2003 16:46:57 GMT"/>
</widget>
</child>
@ -3564,7 +3563,6 @@
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-5</property>
<signal name="clicked" handler="ok_clicked" last_modification_time="Tue, 18 Feb 2003 16:46:37 GMT"/>
</widget>
</child>
</widget>