-/* Copyright (c) 2009, 2010 Nicira Networks
+/* Copyright (c) 2009, 2010, 2011 Nicira Networks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
&& ovsdb_base_type_is_valid(&type->key)
&& ovsdb_base_type_is_valid(&type->value)
&& type->n_min <= 1
- && type->n_min <= type->n_max
&& type->n_max >= 1);
}
def conforms_to_type(self):
n = len(self.values)
- return n >= self.type.n_min and n <= self.type.n_max
+ return self.type.n_min <= n <= self.type.n_max
def cInitDatum(self, var):
if len(self.values) == 0:
-# Copyright (c) 2010 Nicira Networks
+# Copyright (c) 2010, 2011 Nicira Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# XXX still needed?
if type(x) == float:
integer = int(x)
- if integer == x and integer >= -2**53 and integer < 2**53:
+ if integer == x and -2**53 <= integer < 2**53:
return integer
return x
value = default
else:
max_value = 2**32 - 1
- if value < 0 or value > max_value:
+ if not (0 <= value <= max_value):
raise error.Error("%s out of valid range 0 to %d"
% (name, max_value), value)
return value
return (self.key.type != VoidType and self.key.is_valid() and
(self.value is None or
(self.value.type != VoidType and self.value.is_valid())) and
- self.n_min <= 1 and
- self.n_min <= self.n_max and
- self.n_max >= 1)
+ self.n_min <= 1 <= self.n_max)
def is_scalar(self):
return self.n_min == 1 and self.n_max == 1 and not self.value
def __n_from_json(json, default):
if json is None:
return default
- elif type(json) == int and json >= 0 and json <= sys.maxint:
+ elif type(json) == int and 0 <= json <= sys.maxint:
return json
else:
raise error.Error("bad min or max value", json)