From 2b5c8814bd5591af61b350ca74e7a7a85df96e47 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Thu, 18 Nov 2010 12:22:06 +0000 Subject: [PATCH] Allow newer filters to add items to older filters, and still work svn: r16205 --- src/Filters/Rules/_Rule.py | 16 ++++++++++++---- src/gui/filtereditor.py | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Filters/Rules/_Rule.py b/src/Filters/Rules/_Rule.py index f5ff34af4..d5f45e603 100644 --- a/src/Filters/Rules/_Rule.py +++ b/src/Filters/Rules/_Rule.py @@ -28,6 +28,14 @@ #------------------------------------------------------------------------- from gen.ggettext import gettext as _ +#------------------------------------------------------------------------- +# +# enable logging for error handling +# +#------------------------------------------------------------------------- +import logging +log = logging.getLogger(".") + #------------------------------------------------------------------------- # # Rule @@ -88,10 +96,10 @@ class Rule(object): def set_list(self, arg): assert isinstance(arg, list) or arg is None, "Argument is not a list" - assert len(arg) == len(self.labels), \ - "ERROR: Number of arguments does not match number of labels.\n"\ - " list: %s\n"\ - " labels: %s" % (arg,self.labels) + if len(arg) != len(self.labels): + log.warning(("Number of arguments does not match number of labels.\n" + + " list: %s\n" + + " labels: %s") % (arg,self.labels)) self.list = arg def values(self): diff --git a/src/gui/filtereditor.py b/src/gui/filtereditor.py index 7db0bf30d..2c1dabcdf 100644 --- a/src/gui/filtereditor.py +++ b/src/gui/filtereditor.py @@ -569,7 +569,8 @@ class EditRule(ManagedWindow.ManagedWindow): (class_obj, vallist, tlist) = self.page[page] r = self.active_rule.values() for i in range(0, len(tlist)): - tlist[i].set_text(r[i]) + if i < len(r): + tlist[i].set_text(r[i]) self.selection.connect('changed', self.on_node_selected) self.rname.connect('button-press-event', self._button_press)