diff options
author | John L. Villalovos <john.l.villalovos@intel.com> | 2015-08-17 15:05:25 -0700 |
---|---|---|
committer | John L. Villalovos <john.l.villalovos@intel.com> | 2015-08-24 12:17:49 -0700 |
commit | 9b2214ed567e6e84c6654da090ec459e0d339b84 (patch) | |
tree | bac4bd5bb9fe5c3373167345663776f07cfe44f7 /ironic/api/controllers/base.py | |
parent | 16c5e5aecc7ae98cccf8d69029ee638ec98d6b2b (diff) | |
download | ironic-9b2214ed567e6e84c6654da090ec459e0d339b84.tar.gz |
Improve comparison operators for api/controllers/base.py
Improve the comparison operators for api/controllers/base.py. Use the
functools.total_ordering decorator to have it create the rich comparison
operators.
Also added test cases for some of the rich comparison operators.
Change-Id: Iac11df5404aa468a3c41957136fe75624ce4fc70
Diffstat (limited to 'ironic/api/controllers/base.py')
-rw-r--r-- | ironic/api/controllers/base.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/ironic/api/controllers/base.py b/ironic/api/controllers/base.py index 69565cad1..f49ef044d 100644 --- a/ironic/api/controllers/base.py +++ b/ironic/api/controllers/base.py @@ -13,6 +13,7 @@ # under the License. import datetime +import functools from webob import exc import wsme @@ -50,6 +51,7 @@ class APIBase(wtypes.Base): setattr(self, k, wsme.Unset) +@functools.total_ordering class Version(object): """API Version object.""" @@ -103,9 +105,6 @@ class Version(object): "Invalid value for %s header") % Version.string) return version - def __lt__(a, b): - return (a.major, a.minor) < (b.major, b.minor) - def __gt__(a, b): return (a.major, a.minor) > (b.major, b.minor) |