diff options
author | Chris Liechti <cliechti@gmx.net> | 2015-09-04 23:16:16 +0200 |
---|---|---|
committer | Chris Liechti <cliechti@gmx.net> | 2015-09-04 23:16:16 +0200 |
commit | a738a3bbe5d9210402cb8db4cc0c874e51bd865f (patch) | |
tree | b4cfbf4d0907268771764d6e7406259795cdcb1b | |
parent | 0cd7d0759919669b5a53908cad5c3faea0c9f500 (diff) | |
download | pyserial-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.py | 6 | ||||
-rw-r--r-- | serial/tools/list_ports_windows.py | 6 |
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:
|