From: Michael Tremer Date: Tue, 30 Oct 2018 10:12:27 +0000 (+0000) Subject: fireinfo: Fix sorting devices in Python 3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3adfd81b2ac2d976463ee7324cac059114de1372;p=ipfire.org.git fireinfo: Fix sorting devices in Python 3 Signed-off-by: Michael Tremer --- diff --git a/src/backend/fireinfo.py b/src/backend/fireinfo.py index f84df7ad..223468b9 100644 --- a/src/backend/fireinfo.py +++ b/src/backend/fireinfo.py @@ -357,17 +357,18 @@ class Device(Object): return "<%s vendor=%s model=%s>" % (self.__class__.__name__, self.vendor_string, self.model_string) - def __cmp__(self, other): - if self.id and self.id == other.id: - return 0 - - return \ - cmp(self.subsystem, other.subsystem) or \ - cmp(self.vendor_string, other.vendor_string) or \ - cmp(self.vendor, other.vendor) or \ - cmp(self.model_string, other.model_string) or \ - cmp(self.model, other.model) or \ - cmp(self.driver, other.driver) + def __eq__(self, other): + if isinstance(other, self.__class__): + return self.id == other.id + + def __lt__(self, other): + if isinstance(other, self.__class__): + return self.subsystem < other.subsystem or \ + self.vendor_string < other.vendor_string or \ + self.vendor < other.vendor or \ + self.model_string < other.model_string or \ + self.model < other.model or \ + self.driver < other.driver @property def data(self):