Commit ce36ba4b authored by Robert Bradshaw's avatar Robert Bradshaw

Implement warn.all (or any_directive.all).

parent b446c273
...@@ -303,6 +303,11 @@ def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False, ...@@ -303,6 +303,11 @@ def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False,
Traceback (most recent call last): Traceback (most recent call last):
... ...
ValueError: Unknown option: "unknown" ValueError: Unknown option: "unknown"
>>> warnings = parse_directive_list('warn.all=True')
>>> len(warnings) > 1
True
>>> sum(warnings.values()) == len(warnings) # all true.
True
""" """
if current_settings is None: if current_settings is None:
result = {} result = {}
...@@ -313,10 +318,18 @@ def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False, ...@@ -313,10 +318,18 @@ def parse_directive_list(s, relaxed_bool=False, ignore_unknown=False,
if not item: continue if not item: continue
if not '=' in item: raise ValueError('Expected "=" in option "%s"' % item) if not '=' in item: raise ValueError('Expected "=" in option "%s"' % item)
name, value = [ s.strip() for s in item.strip().split('=', 1) ] name, value = [ s.strip() for s in item.strip().split('=', 1) ]
parsed_value = parse_directive_value(name, value, relaxed_bool=relaxed_bool) if name not in directive_defaults:
if parsed_value is None: found = False
if not ignore_unknown: if name.endswith('.all'):
prefix = name[:-3]
for directive in directive_defaults:
if directive.startswith(prefix):
found = True
parsed_value = parse_directive_value(directive, value, relaxed_bool=relaxed_bool)
result[directive] = parsed_value
if not found and not ignore_unknown:
raise ValueError('Unknown option: "%s"' % name) raise ValueError('Unknown option: "%s"' % name)
else: else:
parsed_value = parse_directive_value(name, value, relaxed_bool=relaxed_bool)
result[name] = parsed_value result[name] = parsed_value
return result return result
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment