[schema] implement __eq__ and __lt__ instead of __cmp__ for ERSchema

py3k dropped __cmp__. Related to #267910.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset342166002939
branchdefault
phasedraft
hiddenyes
parent revision#b2ab3ddbb5c4 [schema] deal with py3k's string types
child revision#9899cf1d9446 [schema2sql] get range from six.moves
files modified by this revision
schema.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1413462277 -7200
# Thu Oct 16 14:24:37 2014 +0200
# Node ID 3421660029393edd6b836575432704a06fdbb685
# Parent b2ab3ddbb5c42bd4afe8de3f32365330a197b1c3
[schema] implement __eq__ and __lt__ instead of __cmp__ for ERSchema

py3k dropped __cmp__. Related to #267910.

diff --git a/schema.py b/schema.py
@@ -97,12 +97,15 @@
1          self.schema = schema
2          self.type = erdef.name
3          self.description = erdef.description or ''
4          self.package = erdef.package
5 
6 -    def __cmp__(self, other):
7 -        return cmp(self.type, getattr(other, 'type', other))
8 +    def __eq__(self, other):
9 +        return self.type == getattr(other, 'type', other)
10 +
11 +    def __lt__(self, other):
12 +        return self.type < getattr(other, 'type', other)
13 
14      def __hash__(self):
15          try:
16              return hash(self.type)
17          except AttributeError: