3 MÊ]W§ ã @ s8 d dl Z dd„ ZG dd„ deƒZedkr4eedƒƒ dS )é Nc C sN g }xDt jd| ƒD ]4}|ryt|ƒ}W n tk r: Y nX |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 @ sR e Zd ZdZddd„Zdd„ Zdd„ Zd d „ Zdd„ Zd d„ Z dd„ Z dd„ ZdS )ÚListPortInfoz+Info collection base class for serial portsNc C sF || _ d | _d| _d| _d | _d | _d | _d | _d | _d | _ d | _ d S )Nzn/a)ÚdeviceÚnameÚdescriptionÚhwidÚvidÚpidÚ serial_numberÚlocationZmanufacturerÚproductÚ interface)Úselfr r r r Ú__init__ s zListPortInfo.__init__c C s4 | j dk rdj| j| j ƒS | jdk r*| jS | jS dS )z8return a short string to name the port based on USB infoNz{} - {})r Úformatr r )r r r r Úusb_description. s zListPortInfo.usb_descriptionc C s@ 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={})r r r r r )r r r r Úusb_info7 s zListPortInfo.usb_infoc C s | j ƒ | _| jƒ | _dS )z)update description and hwid from USB dataN)r r r r )r r r r Úapply_usb_info? s zListPortInfo.apply_usb_infoc C s | j |j kS )N)r )r Úotherr r r Ú__eq__D s zListPortInfo.__eq__c C s t | jƒt |jƒk S )N)r r )r r r r r Ú__lt__G s zListPortInfo.__lt__c C s dj | j| jƒS )Nz{} - {})r r r )r r r r Ú__str__J s zListPortInfo.__str__c C s<