From 77633c84ceeaaf5660b3c0000205f9d4e21c0447 Mon Sep 17 00:00:00 2001 From: gwen Date: Mon, 25 Feb 2013 14:27:12 +0100 Subject: [PATCH] private method _get_multitype() --- tiramisu/value.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tiramisu/value.py b/tiramisu/value.py index 74adc5b..44c06ee 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -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):