diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2007-12-15 05:05:08 -0800 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2007-12-18 01:12:21 -0800 |
commit | 8020012ed9f020790e61e840ac3cbd1b4a5317d9 (patch) | |
tree | a8d0bc99fe2b7c2a3a7336ff15d274dc924b6107 /gitosis/configutil.py | |
parent | Pylint fixes for gitdaemon.py, includes refactoring of set_export_ok to make ... (diff) | |
download | gitosis-dakkar-8020012ed9f020790e61e840ac3cbd1b4a5317d9.tar.gz gitosis-dakkar-8020012ed9f020790e61e840ac3cbd1b4a5317d9.tar.bz2 gitosis-dakkar-8020012ed9f020790e61e840ac3cbd1b4a5317d9.zip |
Add new utility function to get a value from a ConfigParser, with a default if the section or value does not exist.
Diffstat (limited to 'gitosis/configutil.py')
-rw-r--r-- | gitosis/configutil.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gitosis/configutil.py b/gitosis/configutil.py new file mode 100644 index 0000000..e067352 --- /dev/null +++ b/gitosis/configutil.py @@ -0,0 +1,15 @@ +""" +Useful wrapper functions to access ConfigParser structures. +""" +from ConfigParser import NoSectionError, NoOptionError + +def getboolean_default(config, section, option, default_value): + """ + Return the given section.variable, or return the default if no specific + value is set. + """ + try: + value = config.getboolean(section, option) + except (NoSectionError, NoOptionError): + value = default_value + return value |