summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liechti <cliechti@gmx.net>2015-09-04 23:16:16 +0200
committerChris Liechti <cliechti@gmx.net>2015-09-04 23:16:16 +0200
commita738a3bbe5d9210402cb8db4cc0c874e51bd865f (patch)
treeb4cfbf4d0907268771764d6e7406259795cdcb1b
parent0cd7d0759919669b5a53908cad5c3faea0c9f500 (diff)
downloadpyserial-git-a738a3bbe5d9210402cb8db4cc0c874e51bd865f.tar.gz
list_ports: add minimal set of methods to info objects to enable sorting again
-rw-r--r--serial/tools/list_ports_linux.py6
-rw-r--r--serial/tools/list_ports_windows.py6
2 files changed, 12 insertions, 0 deletions
diff --git a/serial/tools/list_ports_linux.py b/serial/tools/list_ports_linux.py
index 37dd997..d36254b 100644
--- a/serial/tools/list_ports_linux.py
+++ b/serial/tools/list_ports_linux.py
@@ -83,6 +83,12 @@ class SysFS(object):
else:
return 'n/a'
+ def __eq__(self, other):
+ return self.dev == other.dev
+
+ def __lt__(self, other):
+ return self.dev < other.dev
+
def __getitem__(self, index):
"""Item access: backwards compatible -> (port, desc, hwid)"""
if index == 0:
diff --git a/serial/tools/list_ports_windows.py b/serial/tools/list_ports_windows.py
index 873b088..812d581 100644
--- a/serial/tools/list_ports_windows.py
+++ b/serial/tools/list_ports_windows.py
@@ -168,6 +168,12 @@ class WinInfo(object):
else:
return self.hwid
+ def __eq__(self, other):
+ return self.dev == other.dev
+
+ def __lt__(self, other):
+ return self.dev < other.dev
+
def __getitem__(self, index):
"""Item access: backwards compatible -> (port, desc, hwid)"""
if index == 0: