[svn] commit: r344 - /branches/jelte-datadef/src/lib/cc/python/ISC/CC/data.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Dec 3 12:28:59 UTC 2009
Author: jelte
Date: Thu Dec 3 12:28:59 2009
New Revision: 344
Log:
when parsing literals, return the string itself on ValueError (that way, simple strings don't need quotes in the cli)
Modified:
branches/jelte-datadef/src/lib/cc/python/ISC/CC/data.py
Modified: branches/jelte-datadef/src/lib/cc/python/ISC/CC/data.py
==============================================================================
--- branches/jelte-datadef/src/lib/cc/python/ISC/CC/data.py (original)
+++ branches/jelte-datadef/src/lib/cc/python/ISC/CC/data.py Thu Dec 3 12:28:59 2009
@@ -129,6 +129,13 @@
result.append(name)
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):
@@ -287,7 +294,7 @@
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 @@
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 @@
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)
More information about the bind10-changes
mailing list