1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

- OscConfigParser: added "proper" parameter to the has_option method

This can be used to check if the option belongs to the section or is
just "inherited" from the defaults.
This commit is contained in:
Marcus Huewe 2014-06-04 15:29:50 +02:00
parent a833120ebd
commit e2abfe9e6a

View File

@ -323,6 +323,16 @@ class OscConfigParser(configparser.SafeConfigParser):
else:
configparser.SafeConfigParser.write(self, fp)
def has_option(self, section, option, proper=False, **kwargs):
"""
Returns True, if the passed section contains the specified option.
If proper is True, True is only returned if the option is owned by
this section and not "inherited" from the default.
"""
if proper:
return self.optionxform(option) in self._sections[section].keys()
return configparser.SafeConfigParser.has_option(self, section, option, **kwargs)
# XXX: simplify!
def __str__(self):
ret = []