a zà$Y÷ ã@sPddlZddlZddlZdd„ZGdd„deƒZdd„ZedkrLeed ƒƒdS) éNc CsHg}t d|¡D]2}|rz t|ƒ}Wnty6Yn0| |¡q|S)zc Convert string into a list of texts and numbers in order to support a natural sorting. z(\d+))ÚreÚsplitÚintÚ ValueErrorÚappend)ÚtextÚresultÚgroup©r úB/usr/lib/python3.9/site-packages/serial/tools/list_ports_common.pyÚnumsplits   r c@sReZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)Ú ListPortInfoz+Info collection base class for serial portsNcCsn||_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ |durjt j   |¡rjd t j  |¡¡|_dS)Nzn/azLINK={})ÚdeviceÚnameÚ descriptionÚhwidÚvidÚpidÚ serial_numberÚlocationZ manufacturerÚproductÚ interfaceÚosÚpathÚislinkÚformatÚrealpath)Úselfrr r r Ú__init__"szListPortInfo.__init__cCs4|jdurd |j|j¡S|jdur*|jS|jSdS)z8return a short string to name the port based on USB infoNú{} - {})rrrr©rr r r Úusb_description3s   zListPortInfo.usb_descriptioncCsHd |jp d|jpd|jdur*d |j¡nd|jdurBd |j¡nd¡S)z9return a string with USB related information about devicezUSB VID:PID={:04X}:{:04X}{}{}rNz SER={}Úz LOCATION={})rrrrrr r r r Úusb_info<s üzListPortInfo.usb_infocCs| ¡|_| ¡|_dS)z)update description and hwid from USB dataN)r!rr#rr r r r Úapply_usb_infoDs zListPortInfo.apply_usb_infocCs |j|jkS©N)r©rÚotherr r r Ú__eq__IszListPortInfo.__eq__cCst|jƒt|jƒkSr%)r rr&r r r Ú__lt__LszListPortInfo.__lt__cCsd |j|j¡S)Nr)rrrr r r r Ú__str__OszListPortInfo.__str__cCs<|dkr|jS|dkr|jS|dkr*|jStd |¡ƒ‚dS)z7Item access: backwards compatible -> (port, desc, hwid)rééz{} > 2N)rrrÚ IndexErrorr)rÚindexr r r Ú __getitem__RszListPortInfo.__getitem__)N) Ú__name__Ú __module__Ú __qualname__Ú__doc__rr!r#r$r(r)r*r/r r r r r s  r cCs>g}t d¡D]*}tj |¡rtj |¡|vr| |¡q|S)zd search all /dev devices and look for symlinks to known ports already listed in devices. z/dev/*)Úglobrrrrr)ZdevicesZlinksrr r r Ú list_links^s  r5Ú__main__Zdummy) rr4rr Úobjectr r5r0Úprintr r r r Ú s?