Merge pull request #265 from prculley/bug9755_42

bug 9755, fix duplicated Gramps IDs on Gedcom import (gramps42)
This commit is contained in:
Sam Manzi 2016-11-05 14:06:07 +11:00 committed by GitHub
commit 703703cc75

View File

@ -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
@ -2959,12 +2960,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:
@ -3523,7 +3523,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())
@ -3875,7 +3875,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
@ -5225,7 +5224,6 @@ class GedcomParser(UpdateCallback):
"""
self.__obje(line, state, state.family)
def __family_comm(self, line, state):
"""
@param line: The current line in GedLine format
@ -5561,7 +5559,6 @@ class GedcomParser(UpdateCallback):
"""
self.__obje(line, state, state.event)
def __event_type(self, line, state):
"""
Parses the TYPE line for an event.
@ -5681,7 +5678,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
@ -6319,7 +6315,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)
@ -6329,7 +6325,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)
@ -6346,7 +6342,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)
@ -6359,7 +6355,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)
@ -6379,7 +6375,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
@ -6519,7 +6514,6 @@ class GedcomParser(UpdateCallback):
"""
self.__obje(line, state, state.source)
def __source_chan(self, line, state):
"""
@param line: The current line in GedLine format
@ -6567,7 +6561,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:
@ -6581,7 +6575,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)
@ -7759,7 +7753,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])