is_empty
This commit is contained in:
parent
8be48e5eba
commit
762b0e9c69
1 changed files with 17 additions and 2 deletions
|
@ -80,12 +80,27 @@ class Values(object):
|
||||||
"convenience method to know if an option is empty"
|
"convenience method to know if an option is empty"
|
||||||
if value is not None:
|
if value is not None:
|
||||||
return False
|
return False
|
||||||
if (not opt.is_multi() and self._get_value(opt) == None) or \
|
if (not opt.is_multi() and value == None) or \
|
||||||
(opt.is_multi() and (self._get_value(opt) == [] or \
|
(opt.is_multi() and (value == [] or \
|
||||||
None in self._get_value(opt))):
|
None in self._get_value(opt))):
|
||||||
return True
|
return True
|
||||||
return False
|
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):
|
def _test_mandatory(self, opt, value=None):
|
||||||
# mandatory options
|
# mandatory options
|
||||||
mandatory = self.context._cfgimpl_settings.mandatory
|
mandatory = self.context._cfgimpl_settings.mandatory
|
||||||
|
|
Loading…
Reference in a new issue