From aa2a451f232bfd3231105938fbac912b82847144 Mon Sep 17 00:00:00 2001 From: prculley Date: Tue, 12 Dec 2017 16:06:16 -0600 Subject: [PATCH] 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. --- data/tests/imp_PhonFax_dfs.ged | 6 +++--- data/tests/imp_PhonFax_dfs.gramps | 19 +++++++++++-------- gramps/plugins/lib/libgedcom.py | 31 ++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/data/tests/imp_PhonFax_dfs.ged b/data/tests/imp_PhonFax_dfs.ged index 42dd54126..52ed83a3f 100644 --- a/data/tests/imp_PhonFax_dfs.ged +++ b/data/tests/imp_PhonFax_dfs.ged @@ -1,7 +1,7 @@ 0 HEAD -1 SOUR FTM -2 VERS Family Tree Maker (22.0.0.1410) -2 NAME Family Tree Maker for Windows +1 SOUR Tester +2 VERS 1.0 +2 NAME The Tester 2 CORP Ancestry.com 3 ADDR 360 W 4800 N 4 CONT Provo, UT 84604 diff --git a/data/tests/imp_PhonFax_dfs.gramps b/data/tests/imp_PhonFax_dfs.gramps index 03e4d881e..a8b6ab30b 100644 --- a/data/tests/imp_PhonFax_dfs.gramps +++ b/data/tests/imp_PhonFax_dfs.gramps @@ -3,7 +3,7 @@ "http://gramps-project.org/xml/1.7.1/grampsxml.dtd">
- + The Subm /Tester/ 123 Main St. @@ -109,12 +109,12 @@ Import from imp_FTM_LINK.ged The Tester - - - + + + - + @@ -206,7 +206,8 @@ Only one phone number supported Line 9: 3 PHON (800) 705-7000 Line ignored as not understood Line 15: 2 DATE 1111-01-01 -GEDCOM FORM should be in uppercase Line 26: 2 FORM Lineage-Linked +GEDCOM FORM should be in uppercase Line 26: 2 FORM Lineage-Linked + @@ -214,7 +215,8 @@ GEDCOM FORM should be in uppercase Line 26: Records not imported into SUBM (Submitter): (@SUBM@) The Subm /Tester/: -Only one phone number supported Line 35: 1 PHON 800-871-3401 +Only one phone number supported Line 35: 1 PHON 800-871-3401 + @@ -234,7 +236,8 @@ Only one phone number supported Line 35: Records not imported into REPO (repository) Gramps ID R0002: -Only one phone number supported Line 93: 1 PHON 800-765-4321 +Only one phone number supported Line 93: 1 PHON 800-765-4321 + diff --git a/gramps/plugins/lib/libgedcom.py b/gramps/plugins/lib/libgedcom.py index 8a4625ae7..a3958f33a 100644 --- a/gramps/plugins/lib/libgedcom.py +++ b/gramps/plugins/lib/libgedcom.py @@ -272,6 +272,8 @@ TOKEN__PHOTO = 132 TOKEN__LINK = 133 TOKEN__PRIM = 134 TOKEN__JUST = 135 +TOKEN__TEXT = 136 +TOKEN__DATE = 137 TOKENS = { "_ADPN" : TOKEN__ADPN, @@ -282,7 +284,7 @@ TOKENS = { "_CAT" : TOKEN_IGNORE, "_CHUR" : TOKEN_IGNORE, "_COMM" : TOKEN__COMM, - "_DATE" : TOKEN_IGNORE, + "_DATE" : TOKEN__DATE, "_DATE2" : TOKEN_IGNORE, "_DETAIL" : TOKEN_IGNORE, "_EMAIL" : TOKEN_EMAIL, @@ -315,6 +317,7 @@ TOKENS = { "_SCHEMA" : TOKEN__SCHEMA, "_SSHOW" : TOKEN_IGNORE, "_STAT" : TOKEN__STAT, + "_TEXT" : TOKEN__TEXT, "_TODO" : TOKEN__TODO, "_TYPE" : TOKEN_TYPE, "_UID" : TOKEN__UID, @@ -1186,6 +1189,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, @@ -2490,7 +2494,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, @@ -4081,6 +4087,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) @@ -4092,6 +4101,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 {0:1} + +1 <> {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 {0:3}