- def __cmp__(a, b):
- return (cmp(b.name, a.name)
- or cmp(a.is_valid(), b.is_valid())
- or cmp(a.is_fake(), b.is_fake()))
+ def _cmp(self, other):
+ # Note reversed name ordering
+ bc = bytescmp(other.name, self.name)
+ if bc != 0:
+ return bc
+ vc = self.is_valid() - other.is_valid()
+ if vc != 0:
+ return vc
+ fc = self.is_fake() - other.is_fake()
+ if fc != 0:
+ return fc
+ return 0
+
+ def __eq__(self, other):
+ return self._cmp(other) == 0
+
+ def __ne__(self, other):
+ return self._cmp(other) != 0
+
+ def __lt__(self, other):
+ return self._cmp(other) < 0
+
+ def __gt__(self, other):
+ return self._cmp(other) > 0
+
+ def __le__(self, other):
+ return self._cmp(other) <= 0
+
+ def __ge__(self, other):
+ return self._cmp(other) >= 0