From f733133c835193a884edcf34e5daff6365745d21 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 23 Jul 2015 17:04:20 +0200 Subject: Options/Types: Fix database OPTIONS parsing This is mostly from 257eb0c17 and 16d3e04cb to allow for setting arbitrary database options since some settings require nested dictionaries, etc. This got lost during merge from maint into master because of the completely different Options parsing. --- src/lib/Bcfg2/Options/Types.py | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'src/lib/Bcfg2/Options') diff --git a/src/lib/Bcfg2/Options/Types.py b/src/lib/Bcfg2/Options/Types.py index ac099e135..ad2e04f10 100644 --- a/src/lib/Bcfg2/Options/Types.py +++ b/src/lib/Bcfg2/Options/Types.py @@ -5,6 +5,7 @@ import os import re import pwd import grp +from Bcfg2.Compat import literal_eval _COMMA_SPLIT_RE = re.compile(r'\s*,\s*') @@ -32,28 +33,10 @@ def colon_list(value): return value.split(':') -def comma_dict(value): - """ Split an option string on commas, optionally surrounded by - whitespace, and split the resulting items again on equals signs, - returning a dict """ - result = dict() - if value: - items = comma_list(value) - for item in items: - if '=' in item: - key, value = item.split(r'=', 1) - if value in ["true", "yes", "on"]: - result[key] = True - elif value in ["false", "no", "off"]: - result[key] = False - else: - try: - result[key] = int(value) - except ValueError: - result[key] = value - else: - result[item] = True - return result +def literal_dict(value): + """ literally evaluate the option in order to allow for arbitrarily nested + dictionaries """ + return literal_eval(value) def anchored_regex_list(value): -- cgit v1.2.3-1-g7c22