Fix setting None for config value
This commit is contained in:
parent
bc64bed102
commit
c4d620f0b9
|
@ -113,29 +113,32 @@ class Config:
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
"""Set the 'key' with 'value'."""
|
"""Set the 'key' with 'value'."""
|
||||||
# Sets the "key" with "value" in the config dict
|
# Sets the "key" with "value" in the config dict
|
||||||
if self.config[key] != value:
|
if self.config[key] == value:
|
||||||
oldtype, newtype = type(self.config[key]), type(value)
|
return
|
||||||
if oldtype != newtype:
|
|
||||||
try:
|
|
||||||
value = oldtype(value)
|
|
||||||
except ValueError:
|
|
||||||
log.warning("Type '%s' invalid for '%s'", newtype, key)
|
|
||||||
return
|
|
||||||
|
|
||||||
log.debug("Setting '%s' to %s of %s", key, value, oldtype)
|
oldtype, newtype = type(self.config[key]), type(value)
|
||||||
|
|
||||||
# Make a copy of the current config prior to changing it
|
if value is not None and oldtype != newtype:
|
||||||
self.previous_config = self.config.copy()
|
|
||||||
self.config[key] = value
|
|
||||||
# Run the set_function for this key if any
|
|
||||||
try:
|
try:
|
||||||
gobject.idle_add(self.set_functions[key], key, value)
|
value = oldtype(value)
|
||||||
except KeyError:
|
except ValueError:
|
||||||
pass
|
log.warning("Type '%s' invalid for '%s'", newtype, key)
|
||||||
try:
|
return
|
||||||
gobject.idle_add(self._change_callback, key, value)
|
|
||||||
except:
|
log.debug("Setting '%s' to %s of %s", key, value, oldtype)
|
||||||
pass
|
|
||||||
|
# Make a copy of the current config prior to changing it
|
||||||
|
self.previous_config = self.config.copy()
|
||||||
|
self.config[key] = value
|
||||||
|
# Run the set_function for this key if any
|
||||||
|
try:
|
||||||
|
gobject.idle_add(self.set_functions[key], key, value)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
gobject.idle_add(self._change_callback, key, value)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
"""Get the value of 'key'. If it is an invalid key then get() will
|
"""Get the value of 'key'. If it is an invalid key then get() will
|
||||||
|
|
Loading…
Reference in New Issue