3 MÊ]W§ ã@s8ddlZdd„ZGdd„deƒZedkr4eedƒƒdS)éNc CsNg}xDtjd|ƒD]4}|ry t|ƒ}Wntk r:YnX|j|ƒqW|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 ú'/usr/lib/python3.6/list_ports_common.pyÚnumsplit s r c@sReZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)Ú ListPortInfoz+Info collection base class for serial portsNcCsF||_d|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ dS)Nzn/a) ÚdeviceÚnameÚ descriptionÚhwidÚvidÚpidÚ serial_numberÚlocationZ manufacturerÚproductÚ interface)Úselfrr r r Ú__init__ szListPortInfo.__init__cCs4|jdk rdj|j|jƒS|jdk r*|jS|jSdS)z8return a short string to name the port based on USB infoNz{} - {})rÚformatrr)rr r r Úusb_description.s   zListPortInfo.usb_descriptioncCs@dj|j|j|jdk r"dj|jƒnd|jdk r:dj|jƒndƒS)z9return a string with USB related information about devicezUSB VID:PID={:04X}:{:04X}{}{}Nz SER={}Úz LOCATION={})rrrrr)rr r r Úusb_info7s zListPortInfo.usb_infocCs|jƒ|_|jƒ|_dS)z)update description and hwid from USB dataN)rrrr)rr r r Úapply_usb_info?s zListPortInfo.apply_usb_infocCs |j|jkS)N)r)rÚotherr r r Ú__eq__DszListPortInfo.__eq__cCst|jƒt|jƒkS)N)r r)rrr r r Ú__lt__GszListPortInfo.__lt__cCsdj|j|jƒS)Nz{} - {})rrr)rr r r Ú__str__JszListPortInfo.__str__cCs<|dkr|jS|dkr|jS|dkr*|jStdj|ƒƒ‚dS)z7Item access: backwards compatible -> (port, desc, hwid)rééz{} > 2N)rrrÚ IndexErrorr)rÚindexr r r Ú __getitem__MszListPortInfo.__getitem__)N) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrr r!r"r'r r r r r s  r Ú__main__Zdummy)rr Úobjectr r(Úprintr r r r Ú s=