From d985980ad72dc8dd0797a1a2aeb3000d80358b55 Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 15 Jul 2016 16:37:27 -0500 Subject: [PATCH] Gedcom import of FTM .ged file containing _LINK tags not supported --- gramps/plugins/lib/libgedcom.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gramps/plugins/lib/libgedcom.py b/gramps/plugins/lib/libgedcom.py index f6a0be772..82e0a3375 100755 --- a/gramps/plugins/lib/libgedcom.py +++ b/gramps/plugins/lib/libgedcom.py @@ -269,6 +269,7 @@ TOKEN__MARN = 129 TOKEN__ADPN = 130 TOKEN__FSFTID = 131 TOKEN__PHOTO = 132 +TOKEN__LINK = 133 TOKENS = { "HEAD" : TOKEN_HEAD, "MEDI" : TOKEN_MEDI, @@ -375,7 +376,7 @@ TOKENS = { "_URL" : TOKEN_URL, "URL" : TOKEN_URL, "_MAR" : TOKEN__MAR, "_MARN" : TOKEN__MARN, "_ADPN" : TOKEN__ADPN, "_FSFTID" : TOKEN__FSFTID, - "_PHOTO" : TOKEN__PHOTO, + "_LINK" : TOKEN__LINK, "_PHOTO" : TOKEN__PHOTO, } ADOPT_NONE = 0 @@ -2315,6 +2316,7 @@ class GedcomParser(UpdateCallback): TOKEN_NOTE : self.__citation_note, TOKEN_RNOTE : self.__citation_note, TOKEN_TEXT : self.__citation_data_text, + TOKEN__LINK : self.__citation_link, } self.func_list.append(self.citation_parse_tbl) @@ -6153,6 +6155,21 @@ class GedcomParser(UpdateCallback): state.citation.add_note(note.get_handle()) + def __citation_link(self, line, state): + """ + Not legal GEDCOM - added to support FTM, converts the _LINK tag to a + note with styled text so link can be followed in reports etc. + """ + note = Note() + tags = StyledTextTag(StyledTextTagType.LINK, line.data, + [(0, len(line.data))]) + note.set_styledtext(StyledText(line.data, [tags])) + gramps_id = self.dbase.find_next_note_gramps_id() + note.set_gramps_id(gramps_id) + note.set_type(NoteType.CITATION) + self.dbase.add_note(note, self.trans) + state.citation.add_note(note.get_handle()) + def __citation_data_note(self, line, state): self.__parse_note(line, state.citation, state.level, state)