better handling of eq/ne/hash in receiver and device objects

This commit is contained in:
Daniel Pavel 2013-04-28 15:02:17 +02:00
parent 674ee9ac9e
commit 6f0b61e6d8
1 changed files with 11 additions and 2 deletions

View File

@ -181,10 +181,10 @@ class PairedDevice(object):
__int__ = __index__
def __eq__(self, other):
return self.serial == other.serial
return other is not None and self.kind == other.kind and self.serial == other.serial
def __ne__(self, other):
return self.serial != other.serial
return other is None or self.kind != other.kind or self.serial != other.serial
def __hash__(self):
return self.serial.__hash__()
@ -359,6 +359,15 @@ class Receiver(object):
return self.__contains__(dev.number)
def __eq__(self, other):
return other is not None and self.kind == other.kind and self.path == other.path
def __ne__(self, other):
return other is None or self.kind != other.kind or self.path != other.path
def __hash__(self):
return self.path.__hash__()
def __str__(self):
return self._str
__unicode__ = __repr__ = __str__