From b353c6ba60b88179a0fd6ee77d06b7c463f67d2f Mon Sep 17 00:00:00 2001 From: gwen Date: Fri, 16 Nov 2012 10:04:25 +0100 Subject: [PATCH] modification of reset's arity --- tiramisu/option.py | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/tiramisu/option.py b/tiramisu/option.py index d692aaf..e69ea2e 100644 --- a/tiramisu/option.py +++ b/tiramisu/option.py @@ -216,27 +216,10 @@ class Option(HiddenBaseType, DisabledBaseType): "config *must* be only the **parent** config (not the toplevel config)" return config._cfgimpl_value_owners[self._name] - def reset(self, config, idx=None): + def reset(self, config): """resets the default value and owner - :param idx: if not None, resets only the element at index idx """ - if self.is_multi(): - if idx is not None: - defval = self.getdefault() - value = getattr(config, self._name) - # if the default is ['a', 'b', 'c'] - if len(defval) > idx: - # and idx = 2 -> there is a value in the default - value.setoption(defval[idx], idx, who='default') - else: - # and idx = 4 -> there is actually no such value in the default - value.setoption(self.default_multi, idx, who='default') - else: - value = Multi(self.getdefault(), config, self) - config.setoption(self._name, value, 'default') - else: - value = self.getdefault() - config.setoption(self._name, value, 'default') + config.setoption(self._name, self.getdefault(), 'default') def is_default_owner(self, config): """ @@ -298,17 +281,18 @@ class Option(HiddenBaseType, DisabledBaseType): class ChoiceOption(Option): opt_type = 'string' - def __init__(self, name, doc, values, default=None, - requires=None, callback=None, callback_params=None, - multi=False, mandatory=False, open_values=False): + def __init__(self, name, doc, values, default=None, default_multi=None, + requires=None, mandatory=False, multi=False, callback=None, + callback_params=None, open_values=False): self.values = values if open_values not in [True, False]: raise ConfigError('Open_values must be a boolean for ' '{0}'.format(name)) self.open_values = open_values super(ChoiceOption, self).__init__(name, doc, default=default, - callback=callback, callback_params=callback_params, - requires=requires, multi=multi, mandatory=mandatory) + default_multi=default_multi, callback=callback, + callback_params=callback_params, requires=requires, + multi=multi, mandatory=mandatory) def _validate(self, value): if not self.open_values: