Return transformed value in get
This commit is contained in:
parent
af6f6b99e9
commit
3ed22ffcbe
1
TODO
1
TODO
@ -2,7 +2,6 @@ Bugs
|
|||||||
====
|
====
|
||||||
|
|
||||||
All kind of FIXMEs
|
All kind of FIXMEs
|
||||||
Display untransformed values for get
|
|
||||||
|
|
||||||
Style
|
Style
|
||||||
=====
|
=====
|
||||||
|
@ -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,7 +300,8 @@ 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))
|
||||||
newval = val.typ.transform(newval)
|
if transformed:
|
||||||
|
newval = val.typ.transform(newval)
|
||||||
return newval
|
return newval
|
||||||
|
|
||||||
@cmdutils.register(name='set', instance='config', maxsplit=2,
|
@cmdutils.register(name='set', instance='config', maxsplit=2,
|
||||||
|
Loading…
Reference in New Issue
Block a user