Commit 7742c462 authored by Jelte Jansen's avatar Jelte Jansen

empty list evaluates to False, so check for None explicitely


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/jelte-configuration@826 e5f2f494-b856-4b98-b285-d166d9295462
parent ffe26df9
...@@ -65,7 +65,6 @@ class DataDefinition: ...@@ -65,7 +65,6 @@ class DataDefinition:
if errors: if errors:
errors.append("The is no config_data for this specification") errors.append("The is no config_data for this specification")
return False return False
errors = []
return _validate_spec_list(data_def['config_data'], full, data, errors) return _validate_spec_list(data_def['config_data'], full, data, errors)
...@@ -207,27 +206,27 @@ def _validate_type(spec, value, errors): ...@@ -207,27 +206,27 @@ def _validate_type(spec, value, errors):
specification""" specification"""
data_type = spec['item_type'] data_type = spec['item_type']
if data_type == "integer" and type(value) != int: if data_type == "integer" and type(value) != int:
if errors: if errors != None:
errors.append(str(value) + " should be an integer") errors.append(str(value) + " should be an integer")
return False return False
elif data_type == "real" and type(value) != float: elif data_type == "real" and type(value) != float:
if errors: if errors != None:
errors.append(str(value) + " should be a real") errors.append(str(value) + " should be a real")
return False return False
elif data_type == "boolean" and type(value) != bool: elif data_type == "boolean" and type(value) != bool:
if errors: if errors != None:
errors.append(str(value) + " should be a boolean") errors.append(str(value) + " should be a boolean")
return False return False
elif data_type == "string" and type(value) != str: elif data_type == "string" and type(value) != str:
if errors: if errors != None:
errors.append(str(value) + " should be a string") errors.append(str(value) + " should be a string")
return False return False
elif data_type == "list" and type(value) != list: elif data_type == "list" and type(value) != list:
if errors: if errors != None:
errors.append(str(value) + " should be a list, not a " + str(value.__class__.__name__)) errors.append(str(value) + " should be a list, not a " + str(value.__class__.__name__))
return False return False
elif data_type == "map" and type(value) != dict: elif data_type == "map" and type(value) != dict:
if errors: if errors != None:
errors.append(str(value) + " should be a map") errors.append(str(value) + " should be a map")
return False return False
else: else:
...@@ -256,7 +255,7 @@ def _validate_spec(spec, full, data, errors): ...@@ -256,7 +255,7 @@ def _validate_spec(spec, full, data, errors):
if item_name in data: if item_name in data:
return _validate_item(spec, data[item_name], errors) return _validate_item(spec, data[item_name], errors)
elif full and not item_optional: elif full and not item_optional:
if errors: if errors != None:
errors.append("non-optional item " + item_name + " missing") errors.append("non-optional item " + item_name + " missing")
return False return False
else: else:
......
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