Disallow all multiline-values

This commit is contained in:
Markus Unterwaditzer 2014-05-01 20:47:39 +02:00
parent 7132ccdebb
commit 9c45a7852a
2 changed files with 7 additions and 2 deletions

View file

@ -30,7 +30,7 @@ def load_config(fname, pair_options=('collections', 'conflict_resolution')):
c = RawConfigParser()
c.read(fname)
get_options = lambda s: dict(parse_options(c.items(s)))
get_options = lambda s: dict(parse_options(c.items(s), section=s))
pairs = {}
storages = {}

View file

@ -59,8 +59,13 @@ def split_dict(d, f):
return a, b
def parse_options(items):
def parse_options(items, section=None):
for key, value in items:
if len(value.splitlines()) > 1:
raise ValueError('Section {!r}, option {!r}: '
'No multiline-values allowed.'
.format(section, key))
if value.lower() in ('yes', 'true', 'on'):
value = True
elif value.lower() in ('no', 'false', 'off'):