From 85100e4c3a68bd9428c40fcace491fdfaab70210 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Fri, 13 Aug 2010 11:18:55 +0200 Subject: [PATCH] fix error message when the value isn't in the choices list --- weboob/tools/backend.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/weboob/tools/backend.py b/weboob/tools/backend.py index d103e980..f9df23f5 100644 --- a/weboob/tools/backend.py +++ b/weboob/tools/backend.py @@ -92,7 +92,7 @@ class BaseBackend(object): self.is_masked = is_masked self.regexp = regexp self.description = description - self.choices=None + self.choices = choices class ConfigError(Exception): pass @@ -132,12 +132,13 @@ class BaseBackend(object): elif isinstance(field.default, float) and not isinstance(value, float): value = float(value) + print value, field.choices if field.choices: if (isinstance(field.choices, (tuple,list)) and not value in field.choices) or \ (isinstance(field.choices, dict) and not value in field.choices.iterkeys()): - raise BaseBackend.ConfigError('Value of "%s" might be in this list: %s' % + raise BaseBackend.ConfigError('Value of "%s" might be in this list: %s' % (name, ', '.join([s for s in (field.choices.iterkeys() if isinstance(field.choices, dict) - else field.choices)])) + else field.choices)]))) self.config[name] = value self.storage = BackendStorage(self.name, storage) self.storage.load(self.STORAGE)