core: better management of default value in getConfig
This commit is contained in:
parent
97630ccab9
commit
6b20989ecc
1 changed files with 21 additions and 11 deletions
|
|
@ -73,7 +73,7 @@ def getConfig(config, section, name, default=None):
|
|||
@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 (str): eventually default to this value, if not None
|
||||
@param default: value to use if not found
|
||||
@return: str, list or dict
|
||||
"""
|
||||
if not section:
|
||||
|
|
@ -81,10 +81,8 @@ def getConfig(config, section, name, default=None):
|
|||
|
||||
try:
|
||||
value = config.get(section, name)
|
||||
except (NoOptionError, NoSectionError) as e:
|
||||
if default is None:
|
||||
raise e
|
||||
value = default
|
||||
except (NoOptionError, NoSectionError):
|
||||
return default
|
||||
|
||||
if name.endswith('_path') or name.endswith('_dir'):
|
||||
value = os.path.expanduser(value)
|
||||
|
|
|
|||
Loading…
Reference in a new issue