From 762b0e9c69a781a2387a97c119251e7a281ba672 Mon Sep 17 00:00:00 2001 From: gwen Date: Tue, 26 Feb 2013 14:31:45 +0100 Subject: [PATCH] is_empty --- tiramisu/value.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tiramisu/value.py b/tiramisu/value.py index f6a71f4..237dd7c 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -80,12 +80,27 @@ class Values(object): "convenience method to know if an option is empty" if value is not None: return False - if (not opt.is_multi() and self._get_value(opt) == None) or \ - (opt.is_multi() and (self._get_value(opt) == [] or \ + if (not opt.is_multi() and value == None) or \ + (opt.is_multi() and (value == [] or \ None in self._get_value(opt))): return True return False + def is_empty(self, opt): + if opt not in self.values: + return True + value = self.values[opt] + if not opt.is_multi(): + if self._get_value(opt) == None: + return True + return False + else: + value = list(value) + for val in value: + if val != None: + return False + return True + def _test_mandatory(self, opt, value=None): # mandatory options mandatory = self.context._cfgimpl_settings.mandatory