diff --git a/src/memory/params.py b/src/memory/params.py index ca8a70c6..359c9bf8 100644 --- a/src/memory/params.py +++ b/src/memory/params.py @@ -329,6 +329,22 @@ class Params(object): value_to_use = value if value is not None else node.getAttribute(attr) # we use value (user defined) if it exist, else we use node's default value if node.getAttribute('type') == 'bool': return value_to_use.lower() not in ('false', '0', 'no') + elif node.getAttribute('type') == 'list': + options = [option for option in node.childNodes if option.nodeName == 'option'] + values = [option.getAttribute('value') for option in options] + if value_to_use not in values: # value_to_use is probably empty + selected = [option for option in options if option.getAttribute('selected') == 'true'] + cat, param = node.parentNode.getAttribute('name'), node.getAttribute('name') + if len(selected) == 1: + value_to_use = selected[0].getAttribute('value') + log.info(_("Unset parameter (%(cat)s, %(param)s) of type list will use the default option '%(value)s'") % + {'cat': cat, 'param': param, 'value': value_to_use}) + return value_to_use + if len(selected) == 0: + log.error(_('Parameter (%(cat)s, %(param)s) of type list has no default option!') % {'cat': cat, 'param': param}) + else: + log.error(_('Parameter (%(cat)s, %(param)s) of type list has more than one default option!') % {'cat': cat, 'param': param}) + raise exceptions.DataError return value_to_use return node.getAttribute(attr)