private method _get_multitype()
This commit is contained in:
parent
7b4f3b5d36
commit
77633c84ce
|
@ -38,10 +38,7 @@ class Values(object):
|
||||||
self.slaves = {}
|
self.slaves = {}
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
def _get_value(self, opt):
|
def _get_multitype(self):
|
||||||
"special case for the multis: they never return None"
|
|
||||||
if opt not in self.values:
|
|
||||||
if opt.is_multi():
|
|
||||||
if opt in self.slaves:
|
if opt in self.slaves:
|
||||||
# slave
|
# slave
|
||||||
multitype = multitypes.slave
|
multitype = multitypes.slave
|
||||||
|
@ -51,6 +48,13 @@ class Values(object):
|
||||||
# FIXME : default value for a multi, we shall work on groups
|
# FIXME : default value for a multi, we shall work on groups
|
||||||
else:
|
else:
|
||||||
multitype = multitypes.default
|
multitype = multitypes.default
|
||||||
|
return multitype
|
||||||
|
|
||||||
|
def _get_value(self, opt):
|
||||||
|
"special case for the multis: they never return None"
|
||||||
|
if opt not in self.values:
|
||||||
|
if opt.is_multi():
|
||||||
|
multitype = self._get_multitype()
|
||||||
return Multi(opt.getdefault(), self.context, opt, multitype)
|
return Multi(opt.getdefault(), self.context, opt, multitype)
|
||||||
else:
|
else:
|
||||||
return opt.getdefault()
|
return opt.getdefault()
|
||||||
|
@ -99,7 +103,8 @@ class Values(object):
|
||||||
_result = [result]
|
_result = [result]
|
||||||
else:
|
else:
|
||||||
_result = result
|
_result = result
|
||||||
return Multi(_result, self.context, opt)
|
multitype = self._get_multitype()
|
||||||
|
return Multi(_result, self.context, opt, multitype)
|
||||||
|
|
||||||
def __getitem__(self, opt):
|
def __getitem__(self, opt):
|
||||||
# options with callbacks
|
# options with callbacks
|
||||||
|
@ -107,7 +112,7 @@ class Values(object):
|
||||||
if opt.has_callback():
|
if opt.has_callback():
|
||||||
if (not opt.is_frozen() or \
|
if (not opt.is_frozen() or \
|
||||||
not opt.is_forced_on_freeze()) and \
|
not opt.is_forced_on_freeze()) and \
|
||||||
not opt.is_default_owner(self):
|
not opt.is_default_owner(self.context):
|
||||||
return self._get_value(opt)
|
return self._get_value(opt)
|
||||||
try:
|
try:
|
||||||
result = opt.getcallback_value(
|
result = opt.getcallback_value(
|
||||||
|
@ -116,7 +121,7 @@ class Values(object):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if opt.is_multi():
|
if opt.is_multi():
|
||||||
value = fill_multi(opt, result)
|
value = self.fill_multi(opt, result)
|
||||||
else:
|
else:
|
||||||
# this result **shall not** be a list
|
# this result **shall not** be a list
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
|
|
Loading…
Reference in New Issue