From 26733443fba56fc69c0fe525a1c74f9b5db045f5 Mon Sep 17 00:00:00 2001 From: Tim G L Lyons Date: Fri, 27 Jan 2012 20:59:35 +0000 Subject: [PATCH] 0002918: Add Gedcom EVENT_TYPE_CITED_FROM and ROLE_IN_EVENT in relation with Source Citation Fields. These are added as data elements with keys EVEN and EVEN:ROLE respectively. svn: r18780 --- src/plugins/export/ExportGedcom.py | 7 ++++++ src/plugins/import/ImportGedcom.py | 2 ++ src/plugins/lib/libgedcom.py | 36 ++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/plugins/export/ExportGedcom.py b/src/plugins/export/ExportGedcom.py index ce3d1b653..fd26882d8 100644 --- a/src/plugins/export/ExportGedcom.py +++ b/src/plugins/export/ExportGedcom.py @@ -1341,6 +1341,13 @@ class GedcomWriter(UpdateCallback): if n and n.get_type() != gen.lib.NoteType.SOURCE_TEXT] self.__note_references(note_list, level+1) self.__photos(citation.get_media_list(), level+1) + + if "EVEN" in citation.get_data_map().keys(): + self.__writeln(level+1, "EVEN", citation.get_data_map()["EVEN"]) + if "EVEN:ROLE" in citation.get_data_map().keys(): + self.__writeln(level+2, "ROLE", + citation.get_data_map()["EVEN:ROLE"]) + def __photo(self, photo, level): """ diff --git a/src/plugins/import/ImportGedcom.py b/src/plugins/import/ImportGedcom.py index 06646ac07..b4e3d6667 100644 --- a/src/plugins/import/ImportGedcom.py +++ b/src/plugins/import/ImportGedcom.py @@ -48,6 +48,8 @@ from QuestionDialog import ErrorDialog, DBErrorDialog from glade import Glade from libmixin import DbMixin import libgedcom +module = __import__("libgedcom") +reload (module) try: import config diff --git a/src/plugins/lib/libgedcom.py b/src/plugins/lib/libgedcom.py index 632536691..353626a14 100644 --- a/src/plugins/lib/libgedcom.py +++ b/src/plugins/lib/libgedcom.py @@ -250,6 +250,7 @@ TOKEN_FACT = 123 TOKEN_EMAIL = 124 TOKEN_WWW = 125 TOKEN_URL = 126 +TOKEN_ROLE = 127 TOKENS = { "HEAD" : TOKEN_HEAD, "MEDI" : TOKEN_MEDI, @@ -318,7 +319,8 @@ TOKENS = { "REFERENCE" : TOKEN_REFN, "RELI" : TOKEN_RELI, "RELIGION" : TOKEN_RELI, "REPO" : TOKEN_REPO, "REPOSITORY" : TOKEN_REPO, "RFN" : TOKEN_RFN, - "RIN" : TOKEN_RIN, "_SCHEMA" : TOKEN__SCHEMA, + "RIN" : TOKEN_RIN, "ROLE" : TOKEN_ROLE, + "_SCHEMA" : TOKEN__SCHEMA, "SEX" : TOKEN_SEX, "SCHEMA" : TOKEN__SCHEMA, "SLGC" : TOKEN_SLGC, "SLGS" : TOKEN_SLGS, "SOUR" : TOKEN_SOUR, "SOURCE" : TOKEN_SOUR, @@ -2044,7 +2046,7 @@ class GedcomParser(UpdateCallback): TOKEN_DATA : self.__citation_data, TOKEN_OBJE : self.__citation_obje, TOKEN_REFN : self.__citation_refn, - TOKEN_EVEN : self.__ignore, + TOKEN_EVEN : self.__citation_even, TOKEN_IGNORE : self.__ignore, TOKEN__LKD : self.__ignore, TOKEN_QUAY : self.__citation_quay, @@ -2226,6 +2228,10 @@ class GedcomParser(UpdateCallback): TOKEN_NOTE : self.__citation_data_note, } + self.citation_even_tbl = { + TOKEN_ROLE : self.__citation_even_role, + } + self.header_sour = { TOKEN_SOUR : self.__header_sour, TOKEN_NAME : self.__ignore, @@ -4923,6 +4929,32 @@ class GedcomParser(UpdateCallback): """ self.__skip_subordinate_levels(state.level+1) + def __citation_even(self, line, state): + """ + Parses the EVEN line of an SOUR instance tag + + @param line: The current line in GedLine format + @type line: GedLine + @param state: The current state + @type state: CurrentState + """ + state.citation.set_data_item("EVEN", line.data) + sub_state = CurrentState(level=state.level+1) + sub_state.citation = state.citation + + self.__parse_level(sub_state, self.citation_even_tbl, self.__undefined) + + def __citation_even_role(self, line, state): + """ + Parses the EVEN line of an SOUR instance tag + + @param line: The current line in GedLine format + @type line: GedLine + @param state: The current state + @type state: CurrentState + """ + state.citation.set_data_item("EVEN:ROLE", line.data) + def __citation_quay(self, line, state): """ Parses the QUAY line of an SOUR instance tag