Created
March 22, 2012 14:59
-
-
Save stpierre/2158833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py | |
index f423bea..9fe8c2b 100644 | |
--- a/src/lib/Server/Plugin.py | |
+++ b/src/lib/Server/Plugin.py | |
@@ -1199,27 +1199,32 @@ class SimpleConfig(FileBacked, | |
self.remove_section(section) | |
self.read(self.name) | |
- def get(self, section, option, default=None): | |
+ def get(self, section, option, **kwargs): | |
""" convenience method for getting config items """ | |
+ default = None | |
+ if 'default' in kwargs: | |
+ default = kwargs['default'] | |
+ del kwargs['default'] | |
try: | |
- return ConfigParser.SafeConfigParser.get(self, section, option) | |
+ return ConfigParser.SafeConfigParser.get(self, section, option, | |
+ **kwargs) | |
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): | |
if default is not None: | |
return default | |
else: | |
raise | |
- def getboolean(self, section, option, default=None): | |
+ def getboolean(self, section, option, **kwargs): | |
""" convenience method for getting boolean config items """ | |
+ default = None | |
+ if 'default' in kwargs: | |
+ default = kwargs['default'] | |
+ del kwargs['default'] | |
try: | |
- return ConfigParser.SafeConfigParser.getboolean(self, | |
- section, option) | |
- except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): | |
- if default is not None: | |
- return default | |
- else: | |
- raise | |
- except ValueError: | |
+ return ConfigParser.SafeConfigParser.getboolean(self, section, | |
+ option, **kwargs) | |
+ except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, | |
+ ValueError): | |
if default is not None: | |
return default | |
else: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment