| 92 | def __str__(self): return 'enum ' + str(constants) |
| 93 | |
| 94 | class EnumValue(object): |
| 95 | __slots__ = ('__value') |
| 96 | def __init__(self, value): self.__value = value |
| 97 | value = property(lambda self: self.__value) |
| 98 | type = property(lambda self: EnumType) |
| 99 | def __hash__(self): return hash(self.__value) |
| 100 | def __cmp__(self, other): |
| 101 | try: |
| 102 | if self.type is other.type: |
| 103 | return cmp(self.__value, other.__value) |
| 104 | else: |
| 105 | raise TypeError, "requires a '%s' object but received a '%s'" % ( self.type.__class__.__name__, other.type.__class__.__name__ ) |
| 106 | except AttributeError: |
| 107 | raise TypeError, "requires a '%s' object but received a '%s'" % ( self.type.__class__.__name__, other.__class__.__name__ ) |
| 108 | def __invert__(self): return constants[maximum - self.__value] |
| 109 | def __nonzero__(self): return bool(self.__value) |
| 110 | def __repr__(self): return str(names[self.__value]) |
| 111 | |
| 112 | maximum = len(names) - 1 |
| 113 | constants = [None] * len(names) |
no outgoing calls
no test coverage detected