private method _get_multitype()
This commit is contained in:
parent
7b4f3b5d36
commit
77633c84ce
|
@ -38,19 +38,23 @@ class Values(object):
|
|||
self.slaves = {}
|
||||
self.context = context
|
||||
|
||||
def _get_multitype(self):
|
||||
if opt in self.slaves:
|
||||
# slave
|
||||
multitype = multitypes.slave
|
||||
elif opt in self.masters:
|
||||
# master
|
||||
multitype = multitypes.master
|
||||
# FIXME : default value for a multi, we shall work on groups
|
||||
else:
|
||||
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():
|
||||
if opt in self.slaves:
|
||||
# slave
|
||||
multitype = multitypes.slave
|
||||
elif opt in self.masters:
|
||||
# master
|
||||
multitype = multitypes.master
|
||||
# FIXME : default value for a multi, we shall work on groups
|
||||
else:
|
||||
multitype = multitypes.default
|
||||
multitype = self._get_multitype()
|
||||
return Multi(opt.getdefault(), self.context, opt, multitype)
|
||||
else:
|
||||
return opt.getdefault()
|
||||
|
@ -99,7 +103,8 @@ class Values(object):
|
|||
_result = [result]
|
||||
else:
|
||||
_result = result
|
||||
return Multi(_result, self.context, opt)
|
||||
multitype = self._get_multitype()
|
||||
return Multi(_result, self.context, opt, multitype)
|
||||
|
||||
def __getitem__(self, opt):
|
||||
# options with callbacks
|
||||
|
@ -107,7 +112,7 @@ class Values(object):
|
|||
if opt.has_callback():
|
||||
if (not opt.is_frozen() or \
|
||||
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)
|
||||
try:
|
||||
result = opt.getcallback_value(
|
||||
|
@ -116,7 +121,7 @@ class Values(object):
|
|||
pass
|
||||
else:
|
||||
if opt.is_multi():
|
||||
value = fill_multi(opt, result)
|
||||
value = self.fill_multi(opt, result)
|
||||
else:
|
||||
# this result **shall not** be a list
|
||||
if isinstance(result, list):
|
||||
|
|
Loading…
Reference in New Issue