From ab9f5e2db85df4e4755f1815b40b044758e39fea Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 18 Jun 2003 02:50:30 +0000 Subject: [PATCH] * src/plugins/WriteGedcom.py: catch filter exceptions * src/GenericFilter.py: eliminate loop detection svn: r1758 --- src/GenericFilter.py | 35 ++++++++++++++++++++--------------- src/plugins/WriteGedcom.py | 12 +++++++++--- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/GenericFilter.py b/src/GenericFilter.py index fb68f047c..42b4bd306 100644 --- a/src/GenericFilter.py +++ b/src/GenericFilter.py @@ -185,8 +185,8 @@ class IsDescendantOf(Rule): return self.map.has_key(p.getId()) def init_list(self,p): - if self.map.has_key(p.getId()) == 1: - loop_error(self.orig,p) +# if self.map.has_key(p.getId()) == 1: +# loop_error(self.orig,p) self.map[p.getId()] = 1 for fam in p.getFamilyList(): @@ -213,8 +213,8 @@ class IsDescendantFamilyOf(Rule): return self.search(p,1) def search(self,p,val): - if self.map.has_key(p.getId()): - loop_error(self.orig,p) +# if self.map.has_key(p.getId()): +# loop_error(self.orig,p) if p.getId() == self.list[0]: self.map[p.getId()] = 1 return 1 @@ -262,8 +262,8 @@ class IsAncestorOf(Rule): return self.map.has_key(p.getId()) def init_ancestor_list(self,p): - if self.map.has_key(p.getId()) == 1: - loop_error(self.orig,p) +# if self.map.has_key(p.getId()) == 1: +# loop_error(self.orig,p) self.map[p.getId()] = 1 fam = p.getMainParents() @@ -637,15 +637,20 @@ class MatchesFilter(Rule): # loop_error # #------------------------------------------------------------------------- -def loop_error(p1,p2): - p1name = p1.getPrimaryName().getName() - p2name = p2.getPrimaryName().getName() - p1id = p1.getId() - p2id = p2.getId() - raise Errors.FilterError(_("Loop detected while applying filter"), - _("A relationship loop was detected between %s [%s] " - "and %s [%s]. This is probably due to an error in the " - "database.") % (p1name,p1id,p2name,p2id)) +# def loop_error(p1,p2): +# p1name = p1.getPrimaryName().getName() +# p2name = p2.getPrimaryName().getName() +# p1id = p1.getId() +# p2id = p2.getId() +# raise Errors.FilterError(_("Loop detected while applying filter"), +# _("A relationship loop was detected between %(person1_name)s " +# "[%(person1_id)s] and %(person2_name)s [%(person2_id)s]. " +# "This is probably due to an error in the " +# "database.") % { +# "person1_name" : p1name, +# "person1_id" : p1id, +# "person2_name" : p2name, +# "person2_id" : p2id}) #------------------------------------------------------------------------- # diff --git a/src/plugins/WriteGedcom.py b/src/plugins/WriteGedcom.py index b39788bd8..7e8e83090 100644 --- a/src/plugins/WriteGedcom.py +++ b/src/plugins/WriteGedcom.py @@ -53,6 +53,7 @@ import Julian import Hebrew import FrenchRepublic import GedcomInfo +import Errors import ansel_utf8 from intl import gettext as _ @@ -455,9 +456,14 @@ class GedcomWriter: for p in self.db.getPersonKeys(): self.plist[p] = 1 else: - for p in cfilter.apply(self.db, self.db.getPersonMap().values()): - self.plist[p.getId()] = 1 - + try: + for p in cfilter.apply(self.db, self.db.getPersonMap().values()): + self.plist[p.getId()] = 1 + except Errors.FilterError, msg: + (m1,m2) = msg.messages() + ErrorDialog(m1,m2) + return + self.flist = {} self.slist = {} for key in self.plist.keys():