X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=python%2Fovs%2Fdb%2Ftypes.py;h=2ca0d2913303849c04dd97110844477dff841c06;hb=530af29c41eb04d355e400871fa58f39002315de;hp=aa0a8eda846c0e5a63861d4b7b83a0ebb5ea043d;hpb=991559357f6a03c3a5b70c053c8c2554aa8d5ee4;p=openvswitch diff --git a/python/ovs/db/types.py b/python/ovs/db/types.py index aa0a8eda..2ca0d291 100644 --- a/python/ovs/db/types.py +++ b/python/ovs/db/types.py @@ -1,4 +1,4 @@ -# 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. @@ -290,14 +290,14 @@ class BaseType(object): return 'at most %s' % commafy(self.max) else: return 'at most %g' % self.max - elif self.min_length is not None and self.max_length is not None: + elif self.min_length != 0 and self.max_length != sys.maxint: if self.min_length == self.max_length: return 'exactly %d characters long' % (self.min_length) else: return 'between %d and %d characters long' % (self.min_length, self.max_length) - elif self.min_length is not None: + elif self.min_length != 0: return 'at least %d characters long' % self.min_length - elif self.max_length is not None: + elif self.max_length != sys.maxint: return 'at most %d characters long' % self.max_length else: return '' @@ -358,11 +358,12 @@ class BaseType(object): elif self.type == StringType: if self.min_length is not None: stmts.append('%s.u.string.minLen = %d;' % (var, self.min_length)) - if self.max_length is not None: + if self.max_length != sys.maxint: stmts.append('%s.u.string.maxLen = %d;' % (var, self.max_length)) elif self.type == UuidType: if self.ref_table is not None: stmts.append('%s.u.uuid.refTableName = "%s";' % (var, escapeCString(self.ref_table))) + stmts.append('%s.u.uuid.refType = OVSDB_REF_%s;' % (var, self.ref_type.upper())) return '\n'.join([indent + stmt for stmt in stmts]) class Type(object): @@ -386,7 +387,7 @@ class Type(object): self.n_min == other.n_min and self.n_max == other.n_max) def __ne__(self, other): - if not isinstance(other, BaseType): + if not isinstance(other, Type): return NotImplemented else: return not (self == other)