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

py3k dropped __cmp__. Related to #267910.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset299b110e1916
branchdefault
phasepublic
hiddenno
parent revision#cfc4e2fb9167 [schema] deal with py3k's string types
child revision#3fb17f99816c [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 299b110e191696dd0559629a4adbe088fa9169e3
# Parent cfc4e2fb9167d6cb9a0a3ac81a4a876e5fc8fa3d
[schema] implement __eq__ and __lt__ instead of __cmp__ for ERSchema

py3k dropped __cmp__. Related to #267910.

diff --git a/schema.py b/schema.py
@@ -99,12 +99,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: