From 1db9fea574c0a432a791d9495a5b724bd8c1803b Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 21 Nov 2005 22:42:05 +0000 Subject: [PATCH] * src/ReadGedcom.py: Properly handle TEXT field in SOUR instances when undefined or unhandled fields are present svn: r5412 --- gramps2/ChangeLog | 4 ++++ gramps2/src/ReadGedcom.py | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 55e47b5ad..363e9c062 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,7 @@ +2005-11-21 Don Allingham + * src/ReadGedcom.py: Properly handle TEXT field in SOUR instances when + undefined or unhandled fields are present + 2005-11-21 Martin Hawlisch * src/MediaView.py (media_update): Redisplay the media object at the top * src/FamilyView.py (drag_data_get): Avoid Traceback when dragging from empty list diff --git a/gramps2/src/ReadGedcom.py b/gramps2/src/ReadGedcom.py index cda76dd9a..a7838ab19 100644 --- a/gramps2/src/ReadGedcom.py +++ b/gramps2/src/ReadGedcom.py @@ -651,13 +651,9 @@ class GedcomParser: def parse_source(self,name,level): self.source = self.find_or_create_source(name[1:-1]) - - note = "" while 1: matches = self.get_next() if int(matches[0]) < level: - if note: - self.source.set_note(note) if not self.source.get_title(): self.source.set_title("No title - ID %s" % self.source.get_gramps_id()) self.db.commit_source(self.source, self.trans) @@ -676,25 +672,28 @@ class GedcomParser: self.source.set_author(matches[2] + self.parse_continue_data(level+1)) elif matches[1] == "PUBL": self.source.set_publication_info(matches[2] + self.parse_continue_data(level+1)) - elif matches[1] == "OBJE": - self.ignore_sub_junk(2) elif matches[1] == "NOTE": note = self.parse_note(matches,self.source,level+1,note) + self.source.set_note(note) elif matches[1] == "TEXT": note = self.source.get_note() d = self.parse_continue_data(level+1) if note: - note = "%s\n%s %s%s" % (note,matches[1],matches[2],d) + note = "%s\n%s %s" % (note,matches[2],d) else: - note = "%s %s%s" % (matches[1],matches[2],d) + note = "%s %s" % (matches[2],d) + self.source.set_note(note.strip()) elif matches[1] == "ABBR": self.source.set_abbreviation(matches[2] + self.parse_continue_data(level+1)) + elif matches[1] in ["OBJE","CHAN","_CAT"]: + self.ignore_sub_junk(2) else: note = self.source.get_note() if note: note = "%s\n%s %s" % (note,matches[1],matches[2]) else: note = "%s %s" % (matches[1],matches[2]) + self.source.set_note(note.strip()) def parse_record(self): while True: @@ -1707,6 +1706,7 @@ class GedcomParser: matches = self.get_next() if int(matches[0]) < level: + source.set_note(note) self.backup() return elif matches[1] == "PAGE": @@ -1719,7 +1719,7 @@ class GedcomParser: d = self.dp.parse(date) source.set_date_object(d) source.set_text(text) - elif matches[1] in ["OBJE","REFN","TEXT"]: + elif matches[1] in ["OBJE","REFN"]: self.ignore_sub_junk(level+1) elif matches[1] == "QUAY": try: @@ -1730,8 +1730,9 @@ class GedcomParser: source.set_confidence_level(val+1) else: source.set_confidence_level(val) - elif matches[1] == "NOTE": + elif matches[1] in ["NOTE","TEXT"]: note = self.parse_comment(matches,source,level+1,note) + print note else: self.barf(level+1)