From bab697bffa9da0c5b9de2888dd6d3db4aaea5762 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Mon, 24 Dec 2007 05:07:25 -0800 Subject: Add utility function for default access to config. --- gitosis/configutil.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gitosis/configutil.py b/gitosis/configutil.py index 42d7b18..3215b85 100644 --- a/gitosis/configutil.py +++ b/gitosis/configutil.py @@ -14,6 +14,16 @@ def getboolean_default(config, section, option, default_value): except (NoSectionError, NoOptionError): value = default_value return value +def get_default(config, section, option, default_value): + """ + Return the given section.variable, or return the default if no specific + value is set. + """ + try: + value = config.get(section, option) + except (NoSectionError, NoOptionError): + value = default_value + return value class GitosisConfigDict(IterableUserDict): def keys(self): -- cgit v1.2.3