From 8e2e1fcd4e59f67aed8cd248f3202fc10971cbde Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Mon, 28 Nov 2011 22:32:44 +0100 Subject: We can now configure each conversation independently, for some options. Fixed #2039. --- src/config.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/config.py') 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 -- cgit v1.2.3