* src/GrampsDb/_ReadGedcom.py: handle inline repositories better

svn: r7228
This commit is contained in:
Don Allingham 2006-08-22 04:27:59 +00:00
parent 7f40a17065
commit cd533318bd
2 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@
of cause of death of cause of death
* src/GrampsDb/_WriteGedcom.py: handle custome events for people (bug * src/GrampsDb/_WriteGedcom.py: handle custome events for people (bug
# 368) # 368)
* src/GrampsDb/_ReadGedcom.py: handle inline repositories better
2006-08-20 Alex Roitman <shura@gramps-project.org> 2006-08-20 Alex Roitman <shura@gramps-project.org>
* src/DataViews/_PersonView.py (column_names): Remove cause of death. * src/DataViews/_PersonView.py (column_names): Remove cause of death.

View File

@ -941,8 +941,9 @@ class GedcomParser(UpdateCallback):
self.ignore_sub_junk(level+1) self.ignore_sub_junk(level+1)
def func_source_repo(self, matches, source, level): def func_source_repo(self, matches, source, level):
gid = matches[2][1:-1]
repo = self.find_or_create_repository(gid)
repo_ref = RelLib.RepoRef() repo_ref = RelLib.RepoRef()
repo = self.find_or_create_repository(matches[2][1:-1])
repo_ref.set_reference_handle(repo.handle) repo_ref.set_reference_handle(repo.handle)
self.parse_repo_ref(matches,repo_ref,level+1) self.parse_repo_ref(matches,repo_ref,level+1)
source.add_repo_reference(repo_ref) source.add_repo_reference(repo_ref)
@ -1104,6 +1105,12 @@ class GedcomParser(UpdateCallback):
def find_or_create_repository(self,gramps_id): def find_or_create_repository(self,gramps_id):
repository = RelLib.Repository() repository = RelLib.Repository()
if not gramps_id:
need_commit = True
gramps_id = self.db.find_next_repository_gramps_id()
else:
need_commit = False
intid = self.rid2id.get(gramps_id) intid = self.rid2id.get(gramps_id)
if self.db.has_repository_handle(intid): if self.db.has_repository_handle(intid):
repository.unserialize(self.db.get_raw_repository_data(intid)) repository.unserialize(self.db.get_raw_repository_data(intid))
@ -1111,6 +1118,8 @@ class GedcomParser(UpdateCallback):
intid = self.find_repository_handle(gramps_id) intid = self.find_repository_handle(gramps_id)
repository.set_handle(intid) repository.set_handle(intid)
repository.set_gramps_id(gramps_id) repository.set_gramps_id(gramps_id)
if need_commit:
self.db.commit_repository(repository, self.trans)
return repository return repository
def find_or_create_object(self, gramps_id): def find_or_create_object(self, gramps_id):