more gedcom fixes

svn: r6876
This commit is contained in:
Don Allingham 2006-06-09 04:46:54 +00:00
parent 92c6e9b0d5
commit 1848acbb89
2 changed files with 34 additions and 11 deletions

View File

@ -210,4 +210,5 @@ tokens = {
"VERSION" : TOKEN_VERS, "WIFE" : TOKEN_WIFE, "VERSION" : TOKEN_VERS, "WIFE" : TOKEN_WIFE,
"_WITN" : TOKEN__WITN, "_WTN" : TOKEN__WTN, "_WITN" : TOKEN__WITN, "_WTN" : TOKEN__WTN,
"_CHUR" : TOKEN_IGNORE,"RELA" : TOKEN_RELA, "_CHUR" : TOKEN_IGNORE,"RELA" : TOKEN_RELA,
"_DETAIL" : TOKEN_IGNORE,"_PREF" : TOKEN__PRIMARY,
} }

View File

@ -444,7 +444,7 @@ class Reader:
val = line[2].translate(_transtable,_delc) val = line[2].translate(_transtable,_delc)
except IndexError: except IndexError:
msg = _("Invalid GEDCOM syntax at line %d was ignored.") % self.index msg = _("Invalid GEDCOM syntax at line %d was ignored.") % self.index
log.warningg(msg) log.warning(msg)
continue continue
try: try:
@ -772,6 +772,11 @@ class GedcomParser(UpdateCallback):
def not_recognized(self,level): def not_recognized(self,level):
msg = _("Line %d was not understood, so it was ignored.") % self.groups[4] msg = _("Line %d was not understood, so it was ignored.") % self.groups[4]
# import traceback
# traceback.print_stack()
#
# print self.groups
self.errmsg(msg) self.errmsg(msg)
self.error_count += 1 self.error_count += 1
self.ignore_sub_junk(level) self.ignore_sub_junk(level)
@ -836,7 +841,7 @@ class GedcomParser(UpdateCallback):
self.parse_submitter_data(1) self.parse_submitter_data(1)
def parse_submitter_data(self,level): def parse_submitter_data(self,level):
while(1): while True:
matches = self.get_next() matches = self.get_next()
if int(matches[0]) < level: if int(matches[0]) < level:
self.backup() self.backup()
@ -1486,6 +1491,8 @@ class GedcomParser(UpdateCallback):
else: else:
val = "%s,%s" % (val,matches[2]) val = "%s,%s" % (val,matches[2])
address.set_street(val) address.set_street(val)
elif matches[1] == TOKEN_DATE:
address.set_date_object(self.extract_date(matches[2]))
elif matches[1] == TOKEN_CITY: elif matches[1] == TOKEN_CITY:
address.set_city(matches[2]) address.set_city(matches[2])
elif matches[1] == TOKEN_STAE: elif matches[1] == TOKEN_STAE:
@ -1625,7 +1632,7 @@ class GedcomParser(UpdateCallback):
event.set_date_object(self.extract_date(matches[2])) event.set_date_object(self.extract_date(matches[2]))
def func_event_source(self, matches, event, level): def func_event_source(self, matches, event, level):
event.add_source_reference(self.handle_source(matches,level+1)) event.add_source_reference(self.handle_source(matches,level))
def func_event_place(self, matches, event, level): def func_event_place(self, matches, event, level):
val = matches[2] val = matches[2]
@ -1719,8 +1726,7 @@ class GedcomParser(UpdateCallback):
"""Reads the data associated with a SOUR reference""" """Reads the data associated with a SOUR reference"""
while True: while True:
matches = self.get_next() matches = self.get_next()
if int(matches[0]) < level: if self.level_is_finished(matches, level):
self.backup()
return return
elif matches[1] == TOKEN_PAGE: elif matches[1] == TOKEN_PAGE:
source.set_page(matches[2]) source.set_page(matches[2])
@ -1732,7 +1738,8 @@ class GedcomParser(UpdateCallback):
d = self.dp.parse(date) d = self.dp.parse(date)
source.set_date_object(d) source.set_date_object(d)
source.set_text(text) source.set_text(text)
elif matches[1] in (TOKEN_OBJE, TOKEN_REFN, TOKEN_EVEN): elif matches[1] in (TOKEN_OBJE, TOKEN_REFN, TOKEN_EVEN,
TOKEN_IGNORE):
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
elif matches[1] == TOKEN_QUAY: elif matches[1] == TOKEN_QUAY:
try: try:
@ -1758,16 +1765,15 @@ class GedcomParser(UpdateCallback):
note = "" note = ""
while True: while True:
matches = self.get_next() matches = self.get_next()
if int(matches[0]) < level: if self.level_is_finished(matches, level):
self.backup() break
return (date,note)
elif matches[1] == TOKEN_DATE: elif matches[1] == TOKEN_DATE:
date = matches[2] date = matches[2]
elif matches[1] == TOKEN_TEXT: elif matches[1] == TOKEN_TEXT:
note = matches[2] note = matches[2]
else: else:
self.not_recognized(level+1) self.not_recognized(level+1)
return None return (date,note)
def parse_marnm(self,person,text): def parse_marnm(self,person,text):
data = text.split() data = text.split()
@ -2020,7 +2026,7 @@ class GedcomParser(UpdateCallback):
note = '' note = ''
handle = self.inline_srcs.get((title,note),Utils.create_id()) handle = self.inline_srcs.get((title,note),Utils.create_id())
self.inline_srcs[(title,note)] = handle self.inline_srcs[(title,note)] = handle
self.parse_source_reference(source_ref,level-1) self.parse_source_reference(source_ref,level)
else: else:
handle = self.find_or_create_source(matches[2][1:-1]).handle handle = self.find_or_create_source(matches[2][1:-1]).handle
self.parse_source_reference(source_ref,level) self.parse_source_reference(source_ref,level)
@ -2187,6 +2193,22 @@ class GedcomParser(UpdateCallback):
name.set_type(RelLib.NameType.AKA) name.set_type(RelLib.NameType.AKA)
state.person.add_alternate_name(name) state.person.add_alternate_name(name)
#
# Create a new state, and parse the remainder of the NAME level
sub_state = CurrentState()
sub_state.person = state.person
sub_state.name = name
sub_state.level = 2
while True:
matches = self.get_next()
if self.level_is_finished(matches,2):
name.set_note(sub_state.get_text())
break
else:
func = self.name_func.get(matches[1],self.func_name_undefined)
func(matches,sub_state)
def func_person_object(self, matches, state): def func_person_object(self, matches, state):
""" """
Currently, the embedded form is not supported Currently, the embedded form is not supported