[Yum-devel] [PATCH] config: Nag on misspelled options.
Zdeněk Pavlas
zpavlas at redhat.com
Thu Aug 16 15:37:41 UTC 2012
Currently, when there's a typo in option name, we ignore it.
Maybe we should report an error there.
---
yum/config.py | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/yum/config.py b/yum/config.py
index 2bf4f45..9e6cc30 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -562,7 +562,7 @@ class BaseConfig(object):
out.append('%s: %r' % (name, value))
return '\n'.join(out)
- def populate(self, parser, section, parent=None):
+ def populate(self, parser, section, parent=None, partial=False):
"""Set option values from an INI file section.
:param parser: :class:`ConfigParser` instance (or subclass)
@@ -582,6 +582,7 @@ class BaseConfig(object):
option = self.optionobj(name)
value = None
if name in opts:
+ opts.remove(name)
value = parser.get(section, name)
else:
# No matching option in this section, try inheriting
@@ -590,6 +591,8 @@ class BaseConfig(object):
if value is not None:
setattr(self, name, value)
+ if opts and not partial:
+ raise Errors.ConfigError, 'No such option %s' % ', '.join(map(repr, opts))
def optionobj(cls, name, exceptions=True):
"""Return the :class:`Option` instance for the given name.
@@ -990,7 +993,7 @@ def readStartupConfig(configfile, root, releasever=None):
parser.readfp(confpp_obj)
except ParsingError, e:
raise Errors.ConfigError("Parsing file failed: %s" % e)
- startupconf.populate(parser, 'main')
+ startupconf.populate(parser, 'main', partial=True)
# Check that plugin paths are all absolute
for path in startupconf.pluginpath:
--
1.7.4.4
More information about the Yum-devel
mailing list