[kupfer] settings: Default config value type is str



commit 3e8698dd67da203dd53d5e56f97dde92675f115e
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Apr 7 22:13:13 2005 +0200

    settings: Default config value type is str
    
    We don't have to pre-declare default values of str type now, since
    configuration keys default to str type.

 kupfer/core/settings.py |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/kupfer/core/settings.py b/kupfer/core/settings.py
index 44081fc..e443de5 100644
--- a/kupfer/core/settings.py
+++ b/kupfer/core/settings.py
@@ -159,24 +159,22 @@ class SettingsController (gobject.GObject, pretty.OutputMixin):
 		"""General interface, but section must exist"""
 		key = key.lower()
 		value = self._config[section].get(key)
-		if section in self.defaults and key in self.defaults[section]:
+		if section in self.defaults:
 			return value
-		else:
-			self.output_info("Settings key", section, key, "is invalid")
+		raise KeyError("Invalid settings section: %s" % section)
 
 	def _set_config(self, section, key, value):
 		"""General interface, but section must exist"""
 		self.output_debug("Set", section, key, "to", value)
 		key = key.lower()
 		oldvalue = self._config[section].get(key)
-		if section in self.defaults and key in self.defaults[section]:
-			value_type = type(oldvalue)
+		if section in self.defaults:
+			value_type = type(oldvalue) if oldvalue is not None else str
 			self._config[section][key] = value_type(value)
 			self.emit("value-changed", section, key, value)
 			self._update_config_save_timer()
 			return True
-		self.output_info("Settings key", section, key, "is invalid")
-		return False
+		raise KeyError("Invalid settings section: %s" % section)
 
 	def _get_raw_config(self, section, key):
 		"""General interface, but section must exist"""



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]