From 3e53d086ea3d49c398822bc5de8a9c4c282ffc5f Mon Sep 17 00:00:00 2001 From: prculley Date: Sun, 30 Oct 2016 15:31:24 -0500 Subject: [PATCH] bug 9755, fix duplicated Gramps IDs on Gedcom import --- gramps/plugins/lib/libgedcom.py | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/gramps/plugins/lib/libgedcom.py b/gramps/plugins/lib/libgedcom.py index f0c45db2f..26bcd424a 100755 --- a/gramps/plugins/lib/libgedcom.py +++ b/gramps/plugins/lib/libgedcom.py @@ -5,6 +5,7 @@ # Copyright (C) 2009-2010 Gary Burton # Copyright (C) 2010 Nick Hall # Copyright (C) 2011 Tim G L Lyons +# Copyright (C) 2016 Paul R. Culley # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -2958,12 +2959,11 @@ class GedcomParser(UpdateCallback): def __find_or_create_note(self, gramps_id): """ - Finds or creates a repository based on the GRAMPS ID. If the ID is + Finds or creates a note based on the GRAMPS ID. If the ID is already used (is in the db), we return the item in the db. Otherwise, - we create a new repository, assign the handle and GRAMPS ID. - - Some GEDCOM "flavors" destroy the specification, and declare the - repository inline instead of in a object. + we create a new note, assign the handle and GRAMPS ID. + If no GRAMPS ID is passed in, we not only make a Note with GID, we + commit it. """ note = Note() if not gramps_id: @@ -3522,7 +3522,7 @@ class GedcomParser(UpdateCallback): if self.use_def_src: repo.set_name(submitter_name) repo.set_handle(create_id()) - repo.set_gramps_id(self.dbase.find_next_repository_gramps_id()) + repo.set_gramps_id(self.rid_map[""]) addr = Address() addr.set_street(state.res.get_address()) @@ -3874,7 +3874,6 @@ class GedcomParser(UpdateCallback): """ self.__obje(line, state, state.person) - def __person_photo(self, line, state): """ This handles the FTM _PHOTO feature, which identifies an OBJE to use @@ -5224,7 +5223,6 @@ class GedcomParser(UpdateCallback): """ self.__obje(line, state, state.family) - def __family_comm(self, line, state): """ @param line: The current line in GedLine format @@ -5560,7 +5558,6 @@ class GedcomParser(UpdateCallback): """ self.__obje(line, state, state.event) - def __event_type(self, line, state): """ Parses the TYPE line for an event. @@ -5680,7 +5677,6 @@ class GedcomParser(UpdateCallback): """ self.__obje(line, state, state.place) - def __event_place_sour(self, line, state): """ @param line: The current line in GedLine format @@ -6318,7 +6314,7 @@ class GedcomParser(UpdateCallback): def __source_text(self, line, state): note = Note() note.set(line.data) - gramps_id = self.dbase.find_next_note_gramps_id() + gramps_id = self.nid_map[""] note.set_gramps_id(gramps_id) note.set_type(NoteType.SOURCE_TEXT) self.dbase.add_note(note, self.trans) @@ -6328,7 +6324,7 @@ class GedcomParser(UpdateCallback): def __citation_data_text(self, line, state): note = Note() note.set(line.data) - gramps_id = self.dbase.find_next_note_gramps_id() + gramps_id = self.nid_map[""] note.set_gramps_id(gramps_id) note.set_type(NoteType.SOURCE_TEXT) self.dbase.add_note(note, self.trans) @@ -6345,7 +6341,7 @@ class GedcomParser(UpdateCallback): line.data, [(0, len(line.data))]) note.set_styledtext(StyledText(line.data, [tags])) - gramps_id = self.dbase.find_next_note_gramps_id() + gramps_id = self.nid_map[""] note.set_gramps_id(gramps_id) note.set_type(NoteType.CITATION) self.dbase.add_note(note, self.trans) @@ -6358,7 +6354,7 @@ class GedcomParser(UpdateCallback): """ note = Note() note.set(line.data) - gramps_id = self.dbase.find_next_note_gramps_id() + gramps_id = self.nid_map[""] note.set_gramps_id(gramps_id) note.set_type(_("Citation Justification")) self.dbase.add_note(note, self.trans) @@ -6378,7 +6374,6 @@ class GedcomParser(UpdateCallback): """ self.__obje(line, state, state.citation) - def __citation_refn(self, line, state): """ Parses the REFN line of an SOUR instance tag @@ -6518,7 +6513,6 @@ class GedcomParser(UpdateCallback): """ self.__obje(line, state, state.source) - def __source_chan(self, line, state): """ @param line: The current line in GedLine format @@ -6566,7 +6560,7 @@ class GedcomParser(UpdateCallback): # This format has no repository name. See http://west- # penwith.org.uk/misc/ftmged.htm which points out this is # incorrect - gid = self.dbase.find_next_repository_gramps_id() + gid = self.rid_map[""] repo = self.__find_or_create_repository(gid) self.dbase.commit_repository(repo, self.trans) else: @@ -6580,7 +6574,7 @@ class GedcomParser(UpdateCallback): # non-standard GEDCOM. gid = self.repo2id.get(line.data) if gid is None: - gid = self.dbase.find_next_repository_gramps_id() + gid = self.rid_map[""] repo = self.__find_or_create_repository(gid) self.repo2id[line.data] = repo.get_gramps_id() repo.set_name(line.data) @@ -7758,7 +7752,7 @@ class GedcomParser(UpdateCallback): handle = self.inline_srcs.get(title, create_id()) src = Source() src.handle = handle - src.gramps_id = self.dbase.find_next_source_gramps_id() + src.gramps_id = self.sid_map[""] self.inline_srcs[title] = handle else: src = self.__find_or_create_source(self.sid_map[line.data])