Allows defaults for un-configured ConfigSectionInterfaces.
* Properties of ConfigSectionInterface classes now return optional default values when section is undefined in the datasource. (Previously, these properties would return None, even when defaults where provided) Change-Id: Ic06d7412aa11dfbbd3e8db03262e815f0cc17dec
This commit is contained in:
@@ -132,35 +132,25 @@ class ConfigParserDataSource(DataSource):
|
||||
|
||||
try:
|
||||
return self._data_source.get(self._section_name, item_name)
|
||||
except ConfigParser.NoOptionError as e:
|
||||
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as e:
|
||||
self._log.error(str(e))
|
||||
return default
|
||||
except ConfigParser.NoSectionError as e:
|
||||
self._log.error(str(e))
|
||||
pass
|
||||
|
||||
def get_raw(self, item_name, default=None):
|
||||
try:
|
||||
return self._data_source.get(self._section_name, item_name,
|
||||
raw=True)
|
||||
except ConfigParser.NoOptionError as e:
|
||||
return self._data_source.get(
|
||||
self._section_name, item_name, raw=True)
|
||||
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as e:
|
||||
self._log.error(str(e))
|
||||
return default
|
||||
except ConfigParser.NoSectionError as e:
|
||||
self._log.error(str(e))
|
||||
pass
|
||||
|
||||
def get_boolean(self, item_name, default=None):
|
||||
|
||||
try:
|
||||
return self._data_source.getboolean(self._section_name,
|
||||
item_name)
|
||||
except ConfigParser.NoOptionError as e:
|
||||
return self._data_source.getboolean(self._section_name, item_name)
|
||||
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as e:
|
||||
self._log.error(str(e))
|
||||
return default
|
||||
except ConfigParser.NoSectionError as e:
|
||||
self._log.error(str(e))
|
||||
pass
|
||||
|
||||
|
||||
class DictionaryDataSource(DataSource):
|
||||
|
||||
Reference in New Issue
Block a user