aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/config.py
diff options
context:
space:
mode:
authoridle sign <idlesign@yandex.ru>2016-12-04 10:41:54 +0700
committeridle sign <idlesign@yandex.ru>2016-12-04 10:41:54 +0700
commit810eb439a629e1b2bc2d078f138126356e95a9bc (patch)
tree9fa332bc5bab74e12dec63c56c61f8c600b53d91 /setuptools/config.py
parent06715b636916cd0a008a973d7a7cdcd16fc2feeb (diff)
downloadexternal_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.py21
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):