Rather than pushing serial port descriptions into strings, and then using regex to identify them, it might be nice to instead return all descriptive features as a dictionary:
$ python list_ports.py
/dev/cu.usbserial-A400fZ3q : {'USB Serial Number': 'A400fZ3q', 'idVendor': 1027, 'USB Product Name': 'FT232R USB UART', 'idProduct': 24577}
/dev/cu.usbmodemfd1241 : {'USB Serial Number': '64935343133351305140', 'idVendor': 9153, 'USB Product Name': 'The Replicator', 'idProduct': 54036}
/dev/cu.usbmodemfd1211 : {'USB Serial Number': '64932343838351917111', 'idVendor': 9025, 'USB Product Name': 'Arduino Uno', 'idProduct': 1}
/dev/cu.Bluetooth-Modem : {}
/dev/cu.Bluetooth-PDA-Sync : {}
/dev/cu.usbserial-A700flx4 : {'USB Serial Number': 'A700flx4', 'idVendor': 1027, 'USB Product Name': 'FT232R USB UART', 'idProduct': 24577}
This could be implemented as an extra parameter to the existing interface, or as a replacement for the current interface. A backwards compatibility mode could be implemented so as not to break anything that was expecting the device strings.
It would also allow for other kinds of information (bluetooth/etc?) to be passed through, without breaking any expectations that the regex parsers might have.
If this looks interesting, i can put together a patch.
My apologies, the above command should have had a -v tag for verbose mode.
For reference, the current implementation looks like this:
/dev/ttyACM0
desc: ttyACM0
hwid: USB VID:PID=2341:0001 SNR=64932343838351917111
/dev/ttyS0
desc: ttyS0
hwid: n/a
(continues)
the current implementation at https://github.com/pyserial/pyserial returns an info object (under Linux and Win32, OSX going to follow) it has attributes for some infos and still suports the old indexed access