equal
deleted
inserted
replaced
20 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
21 |
21 |
22 from warnings import warn |
22 from warnings import warn |
23 from functools import partial |
23 from functools import partial |
24 |
24 |
25 from six import string_types |
25 from six import string_types, integer_types |
26 from six.moves import range |
26 from six.moves import range |
27 |
27 |
28 from logilab.common.decorators import cached |
28 from logilab.common.decorators import cached |
29 from logilab.common.deprecation import deprecated |
29 from logilab.common.deprecation import deprecated |
30 from logilab.common.registry import yes |
30 from logilab.common.registry import yes |
546 |
546 |
547 def __lt__(self, other): |
547 def __lt__(self, other): |
548 raise NotImplementedError('comparison not implemented for %s' % self.__class__) |
548 raise NotImplementedError('comparison not implemented for %s' % self.__class__) |
549 |
549 |
550 def __eq__(self, other): |
550 def __eq__(self, other): |
551 if isinstance(self.eid, (int, long)): |
551 if isinstance(self.eid, integer_types): |
552 return self.eid == other.eid |
552 return self.eid == other.eid |
553 return self is other |
553 return self is other |
554 |
554 |
555 def __hash__(self): |
555 def __hash__(self): |
556 if isinstance(self.eid, (int, long)): |
556 if isinstance(self.eid, integer_types): |
557 return self.eid |
557 return self.eid |
558 return super(Entity, self).__hash__() |
558 return super(Entity, self).__hash__() |
559 |
559 |
560 def __json_encode__(self): |
560 def __json_encode__(self): |
561 """custom json dumps hook to dump the entity's eid |
561 """custom json dumps hook to dump the entity's eid |