diff options
author | Florent Le Coz <louiz@louiz.org> | 2011-11-28 22:32:44 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2012-01-26 10:05:32 +0100 |
commit | 8e2e1fcd4e59f67aed8cd248f3202fc10971cbde (patch) | |
tree | 9b65939bdf329c2b9c94825915c1f21c28a9bd06 /src/config.py | |
parent | 0954c12a075da8cb4bc403b475f04a4d84f57dc5 (diff) | |
download | poezio-8e2e1fcd4e59f67aed8cd248f3202fc10971cbde.tar.gz poezio-8e2e1fcd4e59f67aed8cd248f3202fc10971cbde.tar.bz2 poezio-8e2e1fcd4e59f67aed8cd248f3202fc10971cbde.tar.xz poezio-8e2e1fcd4e59f67aed8cd248f3202fc10971cbde.zip |
We can now configure each conversation independently, for some options.
Fixed #2039.
Diffstat (limited to 'src/config.py')
-rw-r--r-- | src/config.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/config.py b/src/config.py index 8bc0d863..af9c9fbe 100644 --- a/src/config.py +++ b/src/config.py @@ -46,10 +46,26 @@ class Config(RawConfigParser): res = self.getboolean(option, section) else: res = self.getstr(option, section) - except( NoOptionError, NoSectionError): + except (NoOptionError, NoSectionError): return default return res + def get_by_tabname(self, option, default, tabname, fallback=True): + """ + Try to get the value for the option. First we look in + a section named `tabname`, if the option is not present + in the section, we search for the global option if fallback is + True. And we return `default` as a fallback as a last resort. + """ + if tabname in self.sections(): + if option in self.options(tabname): + # We go the tab-specific option + return self.get(option, default, tabname) + if fallback: + # We fallback to the global option + return self.get(option, default) + return default + def __get(self, option, section=DEFSECTION): """ facility for RawConfigParser.get |