More config bugfixes

This commit is contained in:
Florian Bruhin 2014-04-02 16:47:21 +02:00
parent 89e21499c8
commit 45ffa9dece
2 changed files with 7 additions and 10 deletions

View File

@ -149,9 +149,7 @@ class Config:
else: else:
lines += wrapper.wrap('Valid values: {}'.format(', '.join( lines += wrapper.wrap('Valid values: {}'.format(', '.join(
valid_values))) valid_values)))
lines += wrapper.wrap('Default: {}'.format( lines += wrapper.wrap('Default: {}'.format(option.default))
option.default_conf if option.default_conf is not None
else option.default))
return lines return lines
def _str_items(self, section): def _str_items(self, section):
@ -170,7 +168,7 @@ class Config:
section: The section to get the option from. section: The section to get the option from.
option: The option name option: The option name
fallback: A fallback value. fallback: A fallback value.
raw: Whether to get the uninterpolated (but transformed!) value. raw: Whether to get the uninterpolated, untransformed value.
""" """
logging.debug("getting {} -> {}".format(section, option)) logging.debug("getting {} -> {}".format(section, option))
@ -183,7 +181,7 @@ class Config:
return fallback return fallback
else: else:
if raw: if raw:
return val.transformed() return val
newval = self._interpolation.before_get( newval = self._interpolation.before_get(
self, section, option, val.value, self, section, option, val.value,
self.config[section].values) self.config[section].values)

View File

@ -109,19 +109,18 @@ class ValueList:
Attributes: Attributes:
values: An OrderedDict with key as index and value as value. values: An OrderedDict with key as index and value as value.
default: An OrderedDict with the default configuration as strings. default: An OrderedDict with the default configuration as strings.
After __init__, the strings become key/value types.
types: A tuple for (keytype, valuetype) types: A tuple for (keytype, valuetype)
valdict: The "true value" dict. valdict: The "true value" dict.
descriptions: A dict with the description strings for the keys. #descriptions: A dict with the description strings for the keys.
Currently a global empty dict to be compatible with # Currently a global empty dict to be compatible with
KeyValue section. # KeyValue section.
""" """
values = None values = None
default = None default = None
types = None types = None
descriptions = {} #descriptions = {}
def __init__(self): def __init__(self):
"""Wrap types over default values. Take care when overriding this.""" """Wrap types over default values. Take care when overriding this."""