diff options
Diffstat (limited to 'py/python/Ice.py')
-rw-r--r-- | py/python/Ice.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/py/python/Ice.py b/py/python/Ice.py index 5790c64cd8a..e371ffe15fa 100644 --- a/py/python/Ice.py +++ b/py/python/Ice.py @@ -189,6 +189,70 @@ class UserException(Exception): '''The base class for all user-defined exceptions.''' pass +class EnumBase(object): + def __init__(self, _n, _v): + self._name = _n + self._value = _v + + def __str__(self): + return self._name + + __repr__ = __str__ + + def __hash__(self): + return self._value + + def __lt__(self, other): + if isinstance(other, self.__class__): + return self._value < other._value; + elif other == None: + return False + return NotImplemented + + def __le__(self, other): + if isinstance(other, self.__class__): + return self._value <= other._value; + elif other == None: + return False + return NotImplemented + + def __eq__(self, other): + if isinstance(other, self.__class__): + return self._value == other._value; + elif other == None: + return False + return NotImplemented + + def __ne__(self, other): + if isinstance(other, self.__class__): + return self._value != other._value; + elif other == None: + return False + return NotImplemented + + def __gt__(self, other): + if isinstance(other, self.__class__): + return self._value > other._value; + elif other == None: + return False + return NotImplemented + + def __ge__(self, other): + if isinstance(other, self.__class__): + return self._value >= other._value; + elif other == None: + return False + return NotImplemented + + def _getName(self): + return self._name + + def _getValue(self): + return self._value + + name = property(_getName) + value = property(_getValue) + class SlicedData(object): # # Members: |