Add round trip Ancestry.com _APID tag support

Implements #9925
This commit is contained in:
Christopher Horn 2021-05-28 20:41:22 -04:00 committed by Nick Hall
parent 3b59aa3a44
commit dfe221d48e
2 changed files with 25 additions and 0 deletions

View File

@ -999,6 +999,11 @@ class GedcomWriter(UpdateCallback):
self._note_references(source.get_note_list(), 1) self._note_references(source.get_note_list(), 1)
self._change(source.get_change_time(), 1) self._change(source.get_change_time(), 1)
for srcattr in source.get_attribute_list():
if str(srcattr.type) == "_APID":
self._writeln(1, "_APID", srcattr.value)
break
def _notes(self): def _notes(self):
""" """
Write out the list of notes, sorting by Gramps ID. Write out the list of notes, sorting by Gramps ID.
@ -1408,6 +1413,11 @@ class GedcomWriter(UpdateCallback):
self._writeln(level + 2, "ROLE", srcattr.value) self._writeln(level + 2, "ROLE", srcattr.value)
break break
for srcattr in citation.get_attribute_list():
if str(srcattr.type) == "_APID":
self._writeln(level + 1, "_APID", srcattr.value)
break
def _photo(self, photo, level): def _photo(self, photo, level):
""" """
n OBJE @<XREF:OBJE>@ {1:1} n OBJE @<XREF:OBJE>@ {1:1}

View File

@ -275,6 +275,7 @@ TOKEN__PRIM = 134
TOKEN__JUST = 135 TOKEN__JUST = 135
TOKEN__TEXT = 136 TOKEN__TEXT = 136
TOKEN__DATE = 137 TOKEN__DATE = 137
TOKEN__APID = 138
TOKENS = { TOKENS = {
"_ADPN" : TOKEN__ADPN, "_ADPN" : TOKEN__ADPN,
@ -282,6 +283,7 @@ TOKENS = {
"_AKAN" : TOKEN__AKA, "_AKAN" : TOKEN__AKA,
"_ALIA" : TOKEN_ALIA, "_ALIA" : TOKEN_ALIA,
"_ANCES_ORDRE" : TOKEN_IGNORE, "_ANCES_ORDRE" : TOKEN_IGNORE,
"_APID" : TOKEN__APID, # Ancestry.com database and page id
"_CAT" : TOKEN_IGNORE, "_CAT" : TOKEN_IGNORE,
"_CHUR" : TOKEN_IGNORE, "_CHUR" : TOKEN_IGNORE,
"_COMM" : TOKEN__COMM, "_COMM" : TOKEN__COMM,
@ -2304,6 +2306,7 @@ class GedcomParser(UpdateCallback):
TOKEN_TEXT : self.__citation_data_text, TOKEN_TEXT : self.__citation_data_text,
TOKEN__LINK : self.__citation_link, TOKEN__LINK : self.__citation_link,
TOKEN__JUST : self.__citation__just, TOKEN__JUST : self.__citation__just,
TOKEN__APID : self.__citation__apid,
} }
self.func_list.append(self.citation_parse_tbl) self.func_list.append(self.citation_parse_tbl)
@ -2452,6 +2455,7 @@ class GedcomParser(UpdateCallback):
# not legal, but Ultimate Family Tree does this # not legal, but Ultimate Family Tree does this
TOKEN_DATE : self.__ignore, TOKEN_DATE : self.__ignore,
TOKEN_IGNORE : self.__ignore, TOKEN_IGNORE : self.__ignore,
TOKEN__APID : self.__source_attr,
} }
self.func_list.append(self.source_func) self.func_list.append(self.source_func)
@ -6377,6 +6381,17 @@ class GedcomParser(UpdateCallback):
self.dbase.add_note(note, self.trans) self.dbase.add_note(note, self.trans)
state.citation.add_note(note.get_handle()) state.citation.add_note(note.get_handle())
def __citation__apid(self, line, state):
"""
Not legal GEDCOM - added to support Ancestry.com, converts the
_APID tag to an attribute. This tag identifies the location of
the cited page in the relevant Ancestry.com database.
"""
sattr = SrcAttribute()
sattr.set_type("_APID")
sattr.set_value(line.data)
state.citation.add_attribute(sattr)
def __citation_data_note(self, line, state): def __citation_data_note(self, line, state):
self.__parse_note(line, state.citation, state) self.__parse_note(line, state.citation, state)