Fixed gedcom import of bad lines, handled place names better

svn: r425
This commit is contained in:
Don Allingham 2001-09-23 23:18:59 +00:00
parent 0cc35fe527
commit 8b2b833eeb
2 changed files with 41 additions and 3 deletions

View File

@ -510,6 +510,12 @@ class GrampsParser(handler.ContentHandler):
def stop_places(self,tag): def stop_places(self,tag):
self.placeobj = None self.placeobj = None
def stop_placeobj(self,tag):
if self.placeobj.get_title() == "":
loc = self.placeobj.get_main_location()
self.placeobj.set_title(build_place_title(loc))
self.palceobj = None
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# #
# #
@ -921,7 +927,7 @@ class GrampsParser(handler.ContentHandler):
"img" : (start_photo, None), "img" : (start_photo, None),
"place" : (start_place, stop_place), "place" : (start_place, stop_place),
"places" : (None, stop_places), "places" : (None, stop_places),
"placeobj" : (start_placeobj,None), "placeobj" : (start_placeobj,stop_placeobj),
"location" : (start_location,None), "location" : (start_location,None),
"coord" : (start_coord,None), "coord" : (start_coord,None),
"pos" : (start_pos, None), "pos" : (start_pos, None),
@ -1100,3 +1106,29 @@ class GrampsImportParser(GrampsParser):
def start_source(self,attrs): def start_source(self,attrs):
self.source = self.db.findSource(u2l(attrs["id"]),self.smap) self.source = self.db.findSource(u2l(attrs["id"]),self.smap)
def append_value(orig,val):
if orig:
return "%s, %s" % (orig,val)
else:
return val
def build_place_title(loc):
"Builds a title from a location"
city = loc.get_city()
state = loc.get_state()
country = loc.get_country()
county = loc.get_county()
value = ""
if city:
value = city
if county:
value = append_value(value,county)
if state:
value = append_value(value,state)
if country:
value = append_value(value,country)
return value

View File

@ -227,7 +227,13 @@ class GedcomParser:
line = latin_utf8.utf8_to_latin(line) line = latin_utf8.utf8_to_latin(line)
match = lineRE.match(line) match = lineRE.match(line)
if not match: if not match:
raise GedcomParser.SyntaxError, self.lines[self.index] msg = _("Warning: line %d was not understood, so it was ignored.") % self.index
self.error_text_obj.insert_defaults(msg)
msg = "\n\t%s\n" % self.lines[self.index-1]
self.error_text_obj.insert_defaults(msg)
self.error_count = self.error_count + 1
self.update(self.errors_obj,str(self.error_count))
match = lineRE.match("999 XXX XXX")
self.index = self.index + 1 self.index = self.index + 1
return match.groups() return match.groups()