]> git.ipfire.org Git - ipfire.org.git/commitdiff
fireinfo: Fix sorting devices in Python 3
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Oct 2018 10:12:27 +0000 (10:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Oct 2018 10:12:27 +0000 (10:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/fireinfo.py

index f84df7adcf0d3e7b0c83d9d6166c6ceec06a59d4..223468b9328e7172b4fc9c6af26dc82cee6bae66 100644 (file)
@@ -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):