Commit d4a6b8a6 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

when parsing literals, return the string itself on ValueError (that way,...

when parsing literals, return the string itself on ValueError (that way, simple strings don't need quotes in the cli)


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jelte-datadef@344 e5f2f494-b856-4b98-b285-d166d9295462
parent 57979d6e
......@@ -130,6 +130,13 @@ def spec_name_list(spec, prefix="", recurse=False):
return result
def parse_value_str(value_str):
try:
return ast.literal_eval(value_str)
except ValueError as ve:
# simply return the string itself
return value_str
class ConfigData:
def __init__(self, specification):
self.specification = specification
......@@ -287,7 +294,7 @@ class UIConfigData():
def add(self, identifier, value_str):
data_spec = find_spec(self.config.specification, identifier)
value = ast.literal_eval(value_str)
value = parse_value_str(value_str)
check_type(data_spec, [value])
cur_list = find_no_exc(self.config_changes, identifier)
if not cur_list:
......@@ -300,7 +307,7 @@ class UIConfigData():
def remove(self, identifier, value_str):
data_spec = find_spec(self.config.specification, identifier)
value = ast.literal_eval(value_str)
value = parse_value_str(value_str)
check_type(data_spec, [value])
cur_list = find_no_exc(self.config_changes, identifier)
if not cur_list:
......@@ -313,7 +320,7 @@ class UIConfigData():
def set(self, identifier, value_str):
data_spec = find_spec(self.config.specification, identifier)
value = ast.literal_eval(value_str)
value = parse_value_str(value_str)
check_type(data_spec, value)
set(self.config_changes, identifier, value)
......
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