From f2c536ffc8207b30d2925951624908ec63353083 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Mon, 15 Sep 2014 09:45:48 +0200 Subject: [PATCH] ability to set value to an empty string if it is available in choices --- weboob/tools/value.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weboob/tools/value.py b/weboob/tools/value.py index 001709b6..92bfaec2 100644 --- a/weboob/tools/value.py +++ b/weboob/tools/value.py @@ -85,13 +85,13 @@ class Value(object): """ if self.default is not None and v == self.default: return - if v == '' and self.default != '': + if v == '' and self.default != '' and (self.choices is None or v not in self.choices): raise ValueError('Value can\'t be empty') if self.regexp is not None and not re.match(self.regexp, unicode(v)): raise ValueError('Value "%s" does not match regexp "%s"' % (v, self.regexp)) - if self.choices is not None and not v in self.choices.iterkeys(): + if self.choices is not None and not v in self.choices: raise ValueError('Value "%s" is not in list: %s' % ( - v, ', '.join(unicode(s) for s in self.choices.iterkeys()))) + v, ', '.join(unicode(s) for s in self.choices))) def load(self, domain, v, callbacks): """