Fix Gedcom import for multiple notes on OBJE (MULTIMEDIA_LINK) (#782)

Fixes #10277
This commit is contained in:
Paul Culley 2019-02-13 22:32:16 -06:00 committed by Sam Manzi
parent 7a82b78ff9
commit f84c2ecf11
2 changed files with 11 additions and 22 deletions

View File

@ -3,7 +3,7 @@
"http://gramps-project.org/xml/1.7.1/grampsxml.dtd">
<database xmlns="http://gramps-project.org/xml/1.7.1/">
<header>
<created date="2017-05-30" version="5.0.0-alpha1"/>
<created date="2019-02-01" version="5.0.2"/>
<researcher>
</researcher>
</header>
@ -66,6 +66,7 @@
<object handle="_0000000300000003" change="1" id="O0000">
<file src="test_emb_55.jpg" mime="image/jpeg" description="Multimedia link embedded form v5.5"/>
<noteref hlink="_0000000200000002"/>
<noteref hlink="_0000000b0000000b"/>
</object>
<object handle="_0000000400000004" change="548708291" id="M1">
<file src="" mime="" description="Multimedia link to linked form v5.5 blob"/>

View File

@ -2315,8 +2315,8 @@ class GedcomParser(UpdateCallback):
TOKEN_MEDI : self.__media_ref_medi, # v5.5.1
TOKEN_TITL : self.__media_ref_titl,
TOKEN_FILE : self.__media_ref_file,
TOKEN_NOTE : self.__media_ref_note,
TOKEN_RNOTE : self.__media_ref_note,
TOKEN_NOTE : self.__obje_note, # illegal, but often there
TOKEN_RNOTE : self.__obje_note, # illegal, but often there
TOKEN__PRIM : self.__media_ref_prim, # LFT etc.
TOKEN_IGNORE : self.__ignore,
}
@ -5331,7 +5331,7 @@ class GedcomParser(UpdateCallback):
sub_state.attr = None
sub_state.filename = ""
sub_state.title = ""
sub_state.note = ""
sub_state.media = Media()
sub_state.level = state.level + 1
sub_state.prim = ""
@ -5376,7 +5376,7 @@ class GedcomParser(UpdateCallback):
else:
path = sub_state.filename
# Multiple references to the same media silently drops the later
# ones, even if title, notes etc. are different
# ones, even if title, etc. are different
photo_handle = self.media_map.get(path)
if photo_handle is None:
photo = Media()
@ -5391,14 +5391,17 @@ class GedcomParser(UpdateCallback):
else:
photo.set_mime_type(MIME_MAP.get(sub_state.form,
'unknown'))
if sub_state.note:
photo.add_note(sub_state.note)
if sub_state.attr:
photo.attribute_list.append(sub_state.attr)
self.dbase.add_media(photo, self.trans)
self.media_map[path] = photo.handle
else:
photo = self.dbase.get_media_from_handle(photo_handle)
# copy notes to our media
for note in sub_state.media.get_note_list():
photo.add_note(note)
self.dbase.commit_media(photo, self.trans)
if sub_state.prim == "Y":
state.photo = photo.handle
oref = MediaRef()
@ -5458,21 +5461,6 @@ class GedcomParser(UpdateCallback):
return
state.filename = line.data
def __media_ref_note(self, line, state):
"""
+1 <<NOTE_STRUCTURE>> {0:M}
@param line: The current line in GedLine format
@type line: GedLine
@param state: The current state
@type state: CurrentState
"""
obj = Media()
self.__parse_note(line, obj, state)
nlist = obj.get_note_list()
if nlist:
state.note = nlist[0]
def __media_ref_prim(self, line, state):
"""
+1 _PRIM <Y/N> {0:1}