
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
M]W
                 @   s8   d dl Z dd ZG dd deZedkr4eed dS )    Nc             C   sN   g }xDt jd| D ]4}|ryt|}W n tk
r:   Y nX |j| qW |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 Zd ZdZdddZdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )ListPortInfoz+Info collection base class for serial portsNc             C   sF   || _ d | _d| _d| _d | _d | _d | _d | _d | _d | _	d | _
d S )Nzn/a)devicenamedescriptionhwidvidpidserial_numberlocationZmanufacturerproduct	interface)selfr   r
   r
   r   __init__    s    zListPortInfo.__init__c             C   s4   | j dk	rdj| j| j S | jdk	r*| jS | jS dS )z8return a short string to name the port based on USB infoNz{} - {})r   formatr   r   )r   r
   r
   r   usb_description.   s
    

zListPortInfo.usb_descriptionc             C   s@   dj | j| j| jdk	r"dj | jnd| jdk	r:dj | jndS )z9return a string with USB related information about devicezUSB VID:PID={:04X}:{:04X}{}{}Nz SER={} z LOCATION={})r   r   r   r   r   )r   r
   r
   r   usb_info7   s
    zListPortInfo.usb_infoc             C   s   | j  | _| j | _dS )z)update description and hwid from USB dataN)r   r   r   r   )r   r
   r
   r   apply_usb_info?   s    
zListPortInfo.apply_usb_infoc             C   s   | j |j kS )N)r   )r   otherr
   r
   r   __eq__D   s    zListPortInfo.__eq__c             C   s   t | jt |jk S )N)r   r   )r   r   r
   r
   r   __lt__G   s    zListPortInfo.__lt__c             C   s   dj | j| jS )Nz{} - {})r   r   r   )r   r
   r
   r   __str__J   s    zListPortInfo.__str__c             C   s<   |dkr| j S |dkr| jS |dkr*| jS tdj|dS )z7Item access: backwards compatible -> (port, desc, hwid)r         z{} > 2N)r   r   r   
IndexErrorr   )r   indexr
   r
   r   __getitem__M   s    zListPortInfo.__getitem__)N)__name__
__module____qualname____doc__r   r   r   r   r    r!   r"   r'   r
   r
   r
   r   r      s   
	r   __main__Zdummy)r   r   objectr   r(   printr
   r
   r
   r   <module>
   s   =