* src/ReadXML.py: handle _NAME_TRANS keyerror exception

svn: r5586
This commit is contained in:
Don Allingham 2005-12-20 00:01:09 +00:00
parent 33e58d3e2b
commit 835647d309
2 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,6 @@
2005-12-19 Don Allingham <don@gramps-project.org>
* src/ReadXML.py: handle _NAME_TRANS keyerror exception
2005-12-19 Alex Roitman <shura@gramps-project.org> 2005-12-19 Alex Roitman <shura@gramps-project.org>
* src/GrampsBSDDB.py (gramps_upgrade_9): Convert all Name and * src/GrampsBSDDB.py (gramps_upgrade_9): Convert all Name and
Attribute objects to use tuple types. Attribute objects to use tuple types.

View File

@ -421,6 +421,18 @@ class GrampsParser:
"url" : (self.start_url, None) "url" : (self.start_url, None)
} }
self.save_attr = {
"Unknown" : RelLib.Attribute.UNKNOWN,
"Custom" : RelLib.Attribute.CUSTOM,
"Caste" : RelLib.Attribute.CASTE,
"Description" : RelLib.Attribute.DESCRIPTION,
"Identification Number" : RelLib.Attribute.ID,
"National Origin" : RelLib.Attribute.NATIONAL,
"Number of Children" : RelLib.Attribute.NUM_CHILD,
"Social Security Number" : RelLib.Attribute.SSN,
"Number of Children" : RelLib.Attribute.NUM_CHILD,
}
self.save_event = { self.save_event = {
"Unknown" : RelLib.Event.UNKNOWN, "Unknown" : RelLib.Event.UNKNOWN,
"Custom" : RelLib.Event.CUSTOM, "Custom" : RelLib.Event.CUSTOM,
@ -737,8 +749,12 @@ class GrampsParser:
self.attribute.conf = 2 self.attribute.conf = 2
if attrs.has_key("priv"): if attrs.has_key("priv"):
self.attribute.private = int(attrs["priv"]) self.attribute.private = int(attrs["priv"])
if attrs.has_key('type'):
self.attribute.set_type(attrs["type"]) atype = self.save_attr.get(attrs["type"],RelLib.Attribute.CUSTOM)
if atype == RelLib.Attribute.CUSTOM:
self.attribute.set_type((atype,attrs["type"]))
else:
self.attribute.set_type((atype,u""))
if attrs.has_key('value'): if attrs.has_key('value'):
self.attribute.set_value(attrs["value"]) self.attribute.set_value(attrs["value"])
if self.photo: if self.photo:
@ -902,7 +918,7 @@ class GrampsParser:
if not self.in_witness: if not self.in_witness:
self.name = RelLib.Name() self.name = RelLib.Name()
if attrs.has_key("type"): if attrs.has_key("type"):
tval = _NAME_TRANS[attrs['type']] tval = _NAME_TRANS.get(attrs['type'],RelLib.Name.CUSTOM)
if tval == RelLib.Name.CUSTOM: if tval == RelLib.Name.CUSTOM:
self.name.set_type((tval,attrs["type"])) self.name.set_type((tval,attrs["type"]))
else: else:
@ -1338,7 +1354,6 @@ class GrampsParser:
self.name.set_type("Birth Name") self.name.set_type("Birth Name")
self.person.set_primary_name (self.name) self.person.set_primary_name (self.name)
self.person.get_primary_name().build_sort_name() self.person.get_primary_name().build_sort_name()
self.name = None self.name = None
def stop_ref(self,tag): def stop_ref(self,tag):