Suport FTM 2017 Gedcom tags on import

Bug #10285
FTM adds subordinate PLAC and OBJE data to INDI.ADDR which is
non-standard.  So treat it as a Residence Event, instead of an
Address.
FTM puts _DATE and _TEXT tags subordinate to OBJE, also non-standard.
This commit is contained in:
prculley 2017-12-12 16:06:16 -06:00 committed by Nick Hall
parent a339e68877
commit 5490ff0b84

View File

@ -274,6 +274,8 @@ TOKEN__PHOTO = 132
TOKEN__LINK = 133
TOKEN__PRIM = 134
TOKEN__JUST = 135
TOKEN__TEXT = 136
TOKEN__DATE = 137
TOKENS = {
"HEAD" : TOKEN_HEAD, "MEDI" : TOKEN_MEDI,
@ -365,7 +367,7 @@ TOKENS = {
"_WITN" : TOKEN__WITN, "_WTN" : TOKEN__WTN,
"_CHUR" : TOKEN_IGNORE,"RELA" : TOKEN_RELA,
"_DETAIL" : TOKEN_IGNORE,"_PREF" : TOKEN__PRIMARY,
"_LKD" : TOKEN__LKD, "_DATE" : TOKEN_IGNORE,
"_LKD" : TOKEN__LKD, "_DATE" : TOKEN__DATE,
"_SCBK" : TOKEN_IGNORE,"_TYPE" : TOKEN_TYPE,
"_PRIM" : TOKEN__PRIM, "_SSHOW" : TOKEN_IGNORE,
"_PAREN" : TOKEN_IGNORE,"BLOB" : TOKEN_BLOB,
@ -383,7 +385,7 @@ TOKENS = {
"_ADPN" : TOKEN__ADPN, "_FSFTID" : TOKEN__FSFTID,
"_LINK" : TOKEN__LINK, "_PHOTO" : TOKEN__PHOTO,
"_JUST" : TOKEN__JUST, # FTM Citation Quality Justification
"FAX" : TOKEN_FAX,
"FAX" : TOKEN_FAX, "_TEXT" : TOKEN__TEXT,
}
ADOPT_NONE = 0
@ -1059,6 +1061,7 @@ class GedLine:
_MAP_DATA = {
TOKEN_UNKNOWN : GedLine.calc_unknown,
TOKEN_DATE : GedLine.calc_date,
TOKEN__DATE : GedLine.calc_date,
TOKEN_SEX : GedLine.calc_sex,
TOKEN_NOTE : GedLine.calc_note,
TOKEN_NCHI : GedLine.calc_nchi,
@ -2550,7 +2553,9 @@ class GedcomParser(UpdateCallback):
TOKEN_TITL : self.__obje_title,
TOKEN_FILE : self.__obje_file, # de-facto extension
TOKEN_TEXT : self.__obje_text, # FTM extension
TOKEN__TEXT : self.__obje_text, # FTM 2017 extension
TOKEN_DATE : self.__obje_date, # FTM extension
TOKEN__DATE : self.__obje_date, # FTM 2017 extension
TOKEN_NOTE : self.__obje_note,
TOKEN_RNOTE : self.__obje_note,
TOKEN_SOUR : self.__obje_sour,
@ -4122,6 +4127,9 @@ class GedcomParser(UpdateCallback):
@param state: The current state
@type state: CurrentState
"""
if self.is_ftw:
self.__person_resi(line, state)
return
free_form = line.data
sub_state = CurrentState(level=state.level + 1)
@ -4133,6 +4141,26 @@ class GedcomParser(UpdateCallback):
self.__merge_address(free_form, sub_state.addr, line, state)
state.person.add_address(sub_state.addr)
def __person_resi(self, line, state):
"""
Parses GEDCOM ADDR tag, subordinate to the INDI tag, when sourced by
FTM. We treat this as a RESI event, because FTM puts standard event
details below the ADDR line.
n ADDR <ADDRESS_LINE> {0:1}
+1 <<EVENT_DETAIL>> {0:1} p.*
@param line: The current line in GedLine format
@type line: GedLine
@param state: The current state
@type state: CurrentState
"""
self.backoff = True # reprocess the current ADDR line
line.level += 1 # as if it was next level down
event_ref = self.__build_event_pair(state, EventType.RESIDENCE,
self.event_parse_tbl, '')
state.person.add_event_ref(event_ref)
def __person_phon(self, line, state):
"""
n PHON <PHONE_NUMBER> {0:3}