aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2007-12-15 05:05:08 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2007-12-18 01:12:21 -0800
commit8020012ed9f020790e61e840ac3cbd1b4a5317d9 (patch)
treea8d0bc99fe2b7c2a3a7336ff15d274dc924b6107
parentPylint fixes for gitdaemon.py, includes refactoring of set_export_ok to make ... (diff)
downloadgitosis-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.
-rw-r--r--gitosis/configutil.py15
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