# HG changeset patch # User Goffi # Date 1413037603 -7200 # Node ID 80d2ed788b40870e512f64bf4a138a1b935a82ce # Parent 9c17bd37e6e599fa1e23537ce9a040c58e7d8db6 core (config): added the Exception default value which raise an exception instead of returning the default in getConfig diff -r 9c17bd37e6e5 -r 80d2ed788b40 src/tools/config.py --- a/src/tools/config.py Tue Oct 07 17:12:41 2014 +0200 +++ b/src/tools/config.py Sat Oct 11 16:26:43 2014 +0200 @@ -73,15 +73,19 @@ @param config (SafeConfigParser): the configuration instance @param section (str): section of the config file (None or '' for DEFAULT) @param name (str): name of the option - @param default: value to use if not found + @param default: value to use if not found, or Exception to raise an exception @return: str, list or dict + @raise: NoOptionError if option is not present and default is Exception + NoSectionError if section doesn't exists and default is Exception """ if not section: section = DEFAULTSECT try: value = config.get(section, name) - except (NoOptionError, NoSectionError): + except (NoOptionError, NoSectionError) as e: + if default is Exception: + raise e return default if name.endswith('_path') or name.endswith('_dir'):