Fixed gedcom import of bad lines, handled place names better
svn: r425
This commit is contained in:
parent
0cc35fe527
commit
8b2b833eeb
@ -510,6 +510,12 @@ class GrampsParser(handler.ContentHandler):
|
||||
def stop_places(self,tag):
|
||||
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),
|
||||
"place" : (start_place, stop_place),
|
||||
"places" : (None, stop_places),
|
||||
"placeobj" : (start_placeobj,None),
|
||||
"placeobj" : (start_placeobj,stop_placeobj),
|
||||
"location" : (start_location,None),
|
||||
"coord" : (start_coord,None),
|
||||
"pos" : (start_pos, None),
|
||||
@ -1100,3 +1106,29 @@ class GrampsImportParser(GrampsParser):
|
||||
def start_source(self,attrs):
|
||||
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
|
||||
|
||||
|
@ -227,7 +227,13 @@ class GedcomParser:
|
||||
line = latin_utf8.utf8_to_latin(line)
|
||||
match = lineRE.match(line)
|
||||
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
|
||||
return match.groups()
|
||||
|
Loading…
Reference in New Issue
Block a user