2006-04-22 Don Allingham <don@gramps-project.org>

* src/GrampsDb/_ReadXML.py: fix Type str_from_xml calls



svn: r6415
This commit is contained in:
Don Allingham 2006-04-22 19:08:47 +00:00
parent 99c3ae0e44
commit 78db7a4ce5
2 changed files with 21 additions and 13 deletions

View File

@ -1,3 +1,6 @@
2006-04-22 Don Allingham <don@gramps-project.org>
* src/GrampsDb/_ReadXML.py: fix Type str_from_xml calls
2006-04-21 Brian Matherly <pez4brian@users.sourceforge.net> 2006-04-21 Brian Matherly <pez4brian@users.sourceforge.net>
* src/PluginUtils/_ReportUtils.py: keep up with RelLib changes * src/PluginUtils/_ReportUtils.py: keep up with RelLib changes
* src/plugins/DetDescendantReport.py: keep up with RelLib changes * src/plugins/DetDescendantReport.py: keep up with RelLib changes

View File

@ -766,7 +766,8 @@ class GrampsParser:
self.eventref = RelLib.EventRef() self.eventref = RelLib.EventRef()
self.eventref.ref = attrs['hlink'].replace('_','') self.eventref.ref = attrs['hlink'].replace('_','')
self.eventref.private = bool(attrs.get('priv')) self.eventref.private = bool(attrs.get('priv'))
self.eventref.role.set_from_xml_str(attrs.get('role')) if attrs.has_key('role'):
self.eventref.role.set_from_xml_str(attrs['role'])
# We count here on events being already parsed prior to parsing # We count here on events being already parsed prior to parsing
# people or families. This code will fail if this is not true. # people or families. This code will fail if this is not true.
event = self.db.get_event_from_handle(self.eventref.ref) event = self.db.get_event_from_handle(self.eventref.ref)
@ -788,7 +789,8 @@ class GrampsParser:
self.attribute.conf = int(attrs.get("conf",2)) self.attribute.conf = int(attrs.get("conf",2))
self.attribute.private = bool(attrs.get("priv")) self.attribute.private = bool(attrs.get("priv"))
self.attribute.type = RelLib.AttributeType() self.attribute.type = RelLib.AttributeType()
self.attribute.type.set_from_xml_str(attrs.get("type",'')) if attrs.has_key('type'):
self.attribute.type.set_from_xml_str(attrs["type"])
self.attribute.value = attrs.get("value",'') self.attribute.value = attrs.get("value",'')
if self.photo: if self.photo:
self.photo.add_attribute(self.attribute) self.photo.add_attribute(self.attribute)
@ -878,8 +880,12 @@ class GrampsParser:
self.childref.ref = attrs['hlink'].replace('_','') self.childref.ref = attrs['hlink'].replace('_','')
self.childref.private = bool(attrs.get('priv')) self.childref.private = bool(attrs.get('priv'))
mrel = RelLib.ChildRefType().set_from_xml_str(attrs.get('mrel')) mrel = RelLib.ChildRefType()
frel = RelLib.ChildRefType().set_from_xml_str(attrs.get('frel')) if attrs.get('mrel'):
mrel.set_from_xml_str(attrs['mrel'])
frel = RelLib.ChildRefType()
if attrs.get('mrel'):
frel.set_from_xml_str(attrs['frel'])
if not mrel.is_default(): if not mrel.is_default():
self.childref.set_mother_relation(mrel) self.childref.set_mother_relation(mrel)
@ -919,7 +925,8 @@ class GrampsParser:
self.family = self.find_family_by_gramps_id(gramps_id) self.family = self.find_family_by_gramps_id(gramps_id)
# GRAMPS LEGACY: the type now belongs to <rel> tag # GRAMPS LEGACY: the type now belongs to <rel> tag
# Here we need to support old format of <family type="Married"> # Here we need to support old format of <family type="Married">
self.family.type.set_from_xml_str(attrs.get("type",'Unknown')) if attrs.has_key('type'):
self.family.type.set_from_xml_str(attrs["type"])
# Old and new markers: complete=1 and marker=word both have to work # Old and new markers: complete=1 and marker=word both have to work
if attrs.get('complete'): # this is only true for complete=1 if attrs.get('complete'): # this is only true for complete=1
@ -928,8 +935,8 @@ class GrampsParser:
self.family.marker.set_from_xml_str(attrs.get("marker",'')) self.family.marker.set_from_xml_str(attrs.get("marker",''))
def start_rel(self,attrs): def start_rel(self,attrs):
self.family.type = RelLib.FamilyRelType().set_from_xml_str( if attrs.has_key('type'):
attrs.get("type",'Unknown')) self.family.type.set_from_xml_str(attrs["type"])
def start_file(self,attrs): def start_file(self,attrs):
self.object.mime = attrs['mime'] self.object.mime = attrs['mime']
@ -953,9 +960,9 @@ class GrampsParser:
# frel and mrel belonged to the "childof" tag # frel and mrel belonged to the "childof" tag
mrel = RelLib.ChildRefType() mrel = RelLib.ChildRefType()
frel = RelLib.ChildRefType() frel = RelLib.ChildRefType()
if attrs.get('mrel'): if attrs.has_key('mrel'):
mrel.set_from_xml_str(attrs['mrel']) mrel.set_from_xml_str(attrs['mrel'])
if attrs.get('frel'): if attrs.has_key('frel'):
frel.set_from_xml_str(attrs['frel']) frel.set_from_xml_str(attrs['frel'])
childref = RelLib.ChildRef() childref = RelLib.ChildRef()
@ -979,7 +986,7 @@ class GrampsParser:
def start_name(self,attrs): def start_name(self,attrs):
if not self.in_witness: if not self.in_witness:
self.name = RelLib.Name() self.name = RelLib.Name()
self.name.type.set_from_xml_str(attrs.get('type')) self.name.type.set_from_xml_str(attrs['type'])
self.name.sort_as = int(attrs.get("sort",RelLib.Name.DEF)) self.name.sort_as = int(attrs.get("sort",RelLib.Name.DEF))
self.name.display_as = int(attrs.get("display",RelLib.Name.DEF)) self.name.display_as = int(attrs.get("display",RelLib.Name.DEF))
self.name.conf = int(attrs.get("conf",2)) self.name.conf = int(attrs.get("conf",2))
@ -1054,8 +1061,7 @@ class GrampsParser:
self.reporef.ref = handle self.reporef.ref = handle
self.reporef.call_number = attrs.get('callno','') self.reporef.call_number = attrs.get('callno','')
self.reporef.media_type = RelLib.SourceMediaType().set_from_xml_str( self.reporef.media_type.set_from_xml_str(attrs['medium'])
attrs.get('medium'))
# we count here on self.source being available # we count here on self.source being available
# reporefs can only be found within source # reporefs can only be found within source
self.source.add_repo_reference(self.reporef) self.source.add_repo_reference(self.reporef)
@ -1387,7 +1393,6 @@ class GrampsParser:
self.event.type.set_from_xml_str(tag) self.event.type.set_from_xml_str(tag)
elif self.repo: elif self.repo:
# Repository type # Repository type
self.repo.type = RelLib.RepositoryType()
self.repo.type.set_from_xml_str(tag) self.repo.type.set_from_xml_str(tag)
def stop_childref(self,tag): def stop_childref(self,tag):