From a62b40a21fa37a888a8e4ccfba37b73174fe80e2 Mon Sep 17 00:00:00 2001 From: RTB Date: Sun, 8 Jun 2014 20:16:30 +0200 Subject: [PATCH] get_section in configurator returns the default section if the requested section does not exist --- utils/configurator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/configurator.py b/utils/configurator.py index 83dee1b..dfc6330 100644 --- a/utils/configurator.py +++ b/utils/configurator.py @@ -63,7 +63,8 @@ class Configurator: def get_section(config, sourcename): """ This function reads a config section labeled in variable sourcename and - tests whether the reliability variable is set else set to empty string + tests whether the reliability variable is set else set to empty string. + Return the default section if the labeled config section does not exist :param config: a ConfigParser object :param sourcename: the name of the section to be read :return a dictionary of the section in the config labeled in sourcename @@ -71,6 +72,8 @@ class Configurator: section = dict() if config.has_section(sourcename): section = dict(config.items(sourcename)) + elif config.defaults(): + section = config.defaults() if 'reliability' not in section: log.msg('Reliability not set for %s' % sourcename, level=log.WARNING)