Return transformed value in get

This commit is contained in:
Florian Bruhin 2014-05-01 20:06:34 +02:00
parent af6f6b99e9
commit 3ed22ffcbe
2 changed files with 5 additions and 4 deletions

1
TODO
View File

@ -2,7 +2,6 @@ Bugs
==== ====
All kind of FIXMEs All kind of FIXMEs
Display untransformed values for get
Style Style
===== =====

View File

@ -267,19 +267,20 @@ class ConfigManager(QObject):
Wrapper for the get-command to output the value in the status bar. Wrapper for the get-command to output the value in the status bar.
""" """
try: try:
val = self.get(section, option) val = self.get(section, option, transformed=False)
except (NoOptionError, NoSectionError) as e: except (NoOptionError, NoSectionError) as e:
message.error("get: {} - {}".format(e.__class__.__name__, e)) message.error("get: {} - {}".format(e.__class__.__name__, e))
else: else:
message.info("{} {} = {}".format(section, option, val)) message.info("{} {} = {}".format(section, option, val))
def get(self, section, option, raw=False): def get(self, section, option, raw=False, transformed=True):
"""Get the value from a section/option. """Get the value from a section/option.
Args: Args:
section: The section to get the option from. section: The section to get the option from.
option: The option name option: The option name
raw: Whether to get the uninterpolated, untransformed value. raw: Whether to get the uninterpolated, untransformed value.
transformed: Whether the value should be transformed.
Return: Return:
The value of the option. The value of the option.
@ -299,6 +300,7 @@ class ConfigManager(QObject):
newval = self._interpolation.before_get(self, section, option, newval = self._interpolation.before_get(self, section, option,
val.value, mapping) val.value, mapping)
logging.debug("interpolated val: {}".format(newval)) logging.debug("interpolated val: {}".format(newval))
if transformed:
newval = val.typ.transform(newval) newval = val.typ.transform(newval)
return newval return newval