diff options
| author | Ben Pfaff <blp@nicira.com> | 2011-08-23 10:06:04 -0700 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2011-08-24 11:57:44 -0700 |
| commit | 71607f575e8eac278b61774faa81fc47b7f8c00b (patch) | |
| tree | bee1d404c981cb9937cfbad5608e7ca30fe9f744 | |
| parent | ca2c5d3d32270210986c76158c0b321aa75e735a (diff) | |
| download | openvswitch-71607f575e8eac278b61774faa81fc47b7f8c00b.tar.gz | |
ovs.db.types: Introduce DEFAULT_MIN, DEFAULT_MAX as Type class members.
Suggested-by: Reid Price <reid@nicira.com>
| -rw-r--r-- | python/ovs/db/types.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/python/ovs/db/types.py b/python/ovs/db/types.py index 5f50d65ea..00b9ab40d 100644 --- a/python/ovs/db/types.py +++ b/python/ovs/db/types.py @@ -365,7 +365,10 @@ class BaseType(object): return '\n'.join([indent + stmt for stmt in stmts]) class Type(object): - def __init__(self, key, value=None, n_min=1, n_max=1): + DEFAULT_MIN = 1 + DEFAULT_MAX = 1 + + def __init__(self, key, value=None, n_min=DEFAULT_MIN, n_max=DEFAULT_MAX): self.key = key self.value = value self.n_min = n_min @@ -442,12 +445,12 @@ class Type(object): else: value = None - n_min = Type.__n_from_json(min_json, 1) + n_min = Type.__n_from_json(min_json, Type.DEFAULT_MIN) if max_json == 'unlimited': n_max = sys.maxint else: - n_max = Type.__n_from_json(max_json, 1) + n_max = Type.__n_from_json(max_json, Type.DEFAULT_MAX) type_ = Type(key, value, n_min, n_max) if not type_.is_valid(): @@ -461,11 +464,11 @@ class Type(object): json = {"key": self.key.to_json()} if self.value is not None: json["value"] = self.value.to_json() - if self.n_min != 1: + if self.n_min != Type.DEFAULT_MIN: json["min"] = self.n_min if self.n_max == sys.maxint: json["max"] = "unlimited" - elif self.n_max != 1: + elif self.n_max != Type.DEFAULT_MAX: json["max"] = self.n_max return json |
