From f04ea9d5be0af00f8dcf3760eb72d2c1dbea6c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Sun, 19 Oct 2008 09:17:02 +0000 Subject: [PATCH] 2404: Note in EventRef in old style XML-data turned into Person note on import (by Michiel Doede Nauta ) svn: r11157 --- src/GrampsDbUtils/_ReadXML.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/GrampsDbUtils/_ReadXML.py b/src/GrampsDbUtils/_ReadXML.py index c44ed4103..24c01bd7e 100644 --- a/src/GrampsDbUtils/_ReadXML.py +++ b/src/GrampsDbUtils/_ReadXML.py @@ -1377,6 +1377,8 @@ class GrampsParser(UpdateCallback): self.note = gen.lib.Note() self.note.handle = Utils.create_id() self.note.format = int(attrs.get('format', gen.lib.Note.FLOWED)) + # The order in this long if-then statement should reflect the + # DTD: most deeply nested elements come first. if self.source_ref: self.note.type.set(gen.lib.NoteType.SOURCEREF) self.note.private = self.source_ref.private @@ -1401,6 +1403,12 @@ class GrampsParser(UpdateCallback): elif self.name: self.note.type.set(gen.lib.NoteType.PERSONNAME) self.note.private = self.name.private + elif self.eventref: + self.note.type.set(gen.lib.NoteType.EVENTREF) + self.note.private = self.eventref.private + elif self.reporef: + self.note.type.set(gen.lib.NoteType.REPOREF) + self.note.private = self.reporef.private elif self.source: self.note.type.set(gen.lib.NoteType.SOURCE) self.note.private = self.source.private @@ -1422,15 +1430,9 @@ class GrampsParser(UpdateCallback): elif self.placeobj: self.note.type.set(gen.lib.NoteType.PLACE) self.note.private = self.placeobj.private - elif self.eventref: - self.note.type.set(gen.lib.NoteType.EVENTREF) - self.note.private = self.eventref.private elif self.repo: self.note.type.set(gen.lib.NoteType.REPO) self.note.private = self.repo.private - elif self.reporef: - self.note.type.set(gen.lib.NoteType.REPOREF) - self.note.private = self.reporef.private self.db.add_note(self.note, self.trans) #set correct change time @@ -1441,6 +1443,8 @@ class GrampsParser(UpdateCallback): handle = attrs['hlink'].replace('_', '') self.db.check_note_from_handle(handle, self.trans, set_gid = False) + # The order in this long if-then statement should reflect the + # DTD: most deeply nested elements come first. if self.source_ref: self.source_ref.add_note(handle) elif self.address: @@ -1457,6 +1461,10 @@ class GrampsParser(UpdateCallback): self.photo.add_note(handle) elif self.name: self.name.add_note(handle) + elif self.eventref: + self.eventref.add_note(handle) + elif self.reporef: + self.reporef.add_note(handle) elif self.source: self.source.add_note(handle) elif self.event: @@ -1471,12 +1479,8 @@ class GrampsParser(UpdateCallback): self.family.add_note(handle) elif self.placeobj: self.placeobj.add_note(handle) - elif self.eventref: - self.eventref.add_note(handle) elif self.repo: self.repo.add_note(handle) - elif self.reporef: - self.reporef.add_note(handle) def start_sourceref(self, attrs): self.source_ref = gen.lib.SourceRef() @@ -2219,6 +2223,8 @@ class GrampsParser(UpdateCallback): self.note.set_styledtext(gen.lib.StyledText(text, self.note_tags)) + # The order in this long if-then statement should reflect the + # DTD: most deeply nested elements come first. if self.address: self.address.add_note(self.note.handle) elif self.ord: @@ -2233,6 +2239,10 @@ class GrampsParser(UpdateCallback): self.photo.add_note(self.note.handle) elif self.name: self.name.add_note(self.note.handle) + elif self.eventref: + self.eventref.add_note(self.note.handle) + elif self.reporef: + self.reporef.add_note(self.note.handle) elif self.source: self.source.add_note(self.note.handle) elif self.event: @@ -2247,12 +2257,8 @@ class GrampsParser(UpdateCallback): self.family.add_note(self.note.handle) elif self.placeobj: self.placeobj.add_note(self.note.handle) - elif self.eventref: - self.eventref.add_note(self.note.handle) elif self.repo: self.repo.add_note(self.note.handle) - elif self.reporef: - self.reporef.add_note(self.note.handle) self.db.commit_note(self.note, self.trans, self.note.get_change_time()) self.note = None