Make it possible to set options with ! in it.

This is needed for a quit! alias for example. The option was wrongly treated as
an inversion even though a value was given.
This commit is contained in:
Florian Bruhin 2015-02-18 23:06:35 +01:00
parent ea2dba6b38
commit 8c32fb86e2

View File

@ -594,7 +594,7 @@ class ConfigManager(QObject):
print_val = True
else:
try:
if optname.endswith('!'):
if optname.endswith('!') and value is None:
val = self.get(sectname, optname[:-1])
layer = 'temp' if temp else 'conf'
if isinstance(val, bool):
@ -602,12 +602,12 @@ class ConfigManager(QObject):
else:
raise cmdexc.CommandError(
"set: Attempted inversion of non-boolean value.")
else:
if value is None:
raise cmdexc.CommandError(
"set: The following arguments are required: value")
elif value is not None:
layer = 'temp' if temp else 'conf'
self.set(layer, sectname, optname, value)
else:
raise cmdexc.CommandError("set: The following arguments "
"are required: value")
except (configexc.Error, configparser.Error) as e:
raise cmdexc.CommandError("set: {} - {}".format(
e.__class__.__name__, e))