def __cmp__(self, other): """Compare me [to another RemoteCache. """ if isinstance(other, self.__class__): return cmp(id(self.__dict__), id(other.__dict__)) else: return cmp(id(self.__dict__), other)
def __cmp__(self, other): """Compare me [to another L{RemoteReference}]. """ if isinstance(other, RemoteReference): if other.broker == self.broker: return cmp(self.luid, other.luid) return cmp(self.broker, other)
def test_equals(self): """ L{cmp} returns 0 for equal objects. """ self.assertEqual(cmp(u"a", u"a"), 0) self.assertEqual(cmp(1, 1), 0) self.assertEqual(cmp([1], [1]), 0)
def __cmp__(self, other): """ Define L{Headers} instances as being equal to each other if they have the same raw headers. """ if isinstance(other, Headers): return cmp(sorted(self._rawHeaders.items()), sorted(other._rawHeaders.items())) return NotImplemented
def __cmp__(self, other): """ Define L{Headers} instances as being equal to each other if they have the same raw headers. """ if isinstance(other, Headers): return cmp( sorted(self._rawHeaders.items()), sorted(other._rawHeaders.items())) return NotImplemented
def test_ordering(self, eventA: Event, eventB: Event) -> None: """ Event ordering corresponds to event ID ordering. """ self.assertEqual(cmp(eventA, eventA), cmp(eventA.id, eventA.id)) self.assertEqual(cmp(eventA, eventB), cmp(eventA.id, eventB.id)) self.assertEqual(cmp(eventB, eventA), cmp(eventB.id, eventA.id))
def __cmp__(self, other): """ Compare two versions, considering major versions, minor versions, micro versions, then prereleases. A version with a prerelease is always less than a version without a prerelease. If both versions have prereleases, they will be included in the comparison. @param other: Another version. @type other: L{Version} @return: NotImplemented when the other object is not a Version, or one of -1, 0, or 1. @raise IncomparableVersions: when the package names of the versions differ. """ if not isinstance(other, self.__class__): return NotImplemented if self.package != other.package: raise IncomparableVersions("%r != %r" % (self.package, other.package)) if self.prerelease is None: prerelease = _inf else: prerelease = self.prerelease if other.prerelease is None: otherpre = _inf else: otherpre = other.prerelease x = cmp((self.major, self.minor, self.micro, prerelease), (other.major, other.minor, other.micro, otherpre)) return x
def __cmp__(self, other): if not isinstance(other, Comparable): return NotImplemented return cmp(self.value, other.value)
def __cmp__(self, other): return cmp(self.num, other.num)
def __cmp__(self, other): return cmp((self.name, self.broker, self.perspective, self.cached), other)
def __cmp__(self, other): """Compare me to another L{RemoteCacheObserver}. """ return cmp((self.broker, self.perspective, self.cached), other)
def __cmp__(self, other): return cmp((self.obj, self.name), other)
def __cmp__(self, other): if not isinstance(other, ZipPath): return NotImplemented return cmp((self.archive, self.pathInArchive), (other.archive, other.pathInArchive))
def test_greaterThan(self): """ L{cmp} returns 1 if its first argument is bigger than its second. """ self.assertEqual(cmp(4, 0), 1) self.assertEqual(cmp(b"z", b"a"), 1)
def test_lessThan(self): """ L{cmp} returns -1 if its first argument is smaller than its second. """ self.assertEqual(cmp(0.1, 2.3), -1) self.assertEqual(cmp(b"a", b"d"), -1)
def __cmp__(self, other): if not isinstance(other, FilePath): return NotImplemented return cmp(self.path, other.path)