diff options
author | idle sign <idlesign@yandex.ru> | 2016-12-04 10:41:54 +0700 |
---|---|---|
committer | idle sign <idlesign@yandex.ru> | 2016-12-04 10:41:54 +0700 |
commit | 810eb439a629e1b2bc2d078f138126356e95a9bc (patch) | |
tree | 9fa332bc5bab74e12dec63c56c61f8c600b53d91 /setuptools/config.py | |
parent | 06715b636916cd0a008a973d7a7cdcd16fc2feeb (diff) | |
download | external_python_setuptools-810eb439a629e1b2bc2d078f138126356e95a9bc.tar.gz external_python_setuptools-810eb439a629e1b2bc2d078f138126356e95a9bc.tar.bz2 external_python_setuptools-810eb439a629e1b2bc2d078f138126356e95a9bc.zip |
Added ConfigHandler.strict_mode.
Diffstat (limited to 'setuptools/config.py')
-rw-r--r-- | setuptools/config.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/setuptools/config.py b/setuptools/config.py index 94b2ab17..3546ace9 100644 --- a/setuptools/config.py +++ b/setuptools/config.py @@ -12,6 +12,16 @@ class ConfigHandler(object): """Handles metadata supplied in configuration files.""" section_prefix = None + """Prefix for config sections handled by this handler. + Must be provided by class heirs. + + """ + + strict_mode = True + """Flag. Whether unknown options in config should + raise DistutilsOptionError exception, or pass silently. + + """ def __init__(self, target_obj, options): sections = {} @@ -174,9 +184,11 @@ class ConfigHandler(object): for (name, (_, value)) in section_options.items(): try: self[name] = value + except KeyError: - raise DistutilsOptionError( - 'Unknown distribution option: %s' % name) + if self.strict_mode: + raise DistutilsOptionError( + 'Unknown distribution option: %s' % name) def parse(self): """Parses configuration file items from one @@ -203,6 +215,11 @@ class ConfigHandler(object): class ConfigMetadataHandler(ConfigHandler): section_prefix = 'metadata' + strict_mode = False + """We need to keep it loose, to be compatible with `pbr` package + which also uses `metadata` section. + + """ @property def parsers(self): |