
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
M]W                 @   s~   d Z ddlZddlZddlZejdkr4ddlmZ n(ejdkrLddlmZ nedj	ejdd Z
d	d
 Zedkrze  dS )aA  This module will provide a function called comports that returns an
iterable (generator or list) that will enumerate available com ports. Note that
on some systems non-existent ports may be listed.

Additionally a grep function is supplied that can be used to search for ports
based on their descriptions or hardware ID.
    Nnt)comportsposixz;Sorry: no implementation for your platform ('{}') availablec             c   sP   t j| t j}x<t D ]2}|\}}}|j|sB|j|sB|j|r|V  qW dS )z    Search for ports using a regular expression. Port name, description and
    hardware ID are searched. The function returns an iterable that returns the
    same tuples as comport() would do.
    N)recompileIr   search)regexprinfoportdeschwid r    /usr/lib/python3.6/list_ports.pygrep%   s
    
r   c        	      C   sJ  dd l } | jdd}|jdddd |jdd	d
dd |jddd
dd |jdtdd |j }d}|jr|jstjj	dj
|j tt|j}n
tt }xxt|dD ]j\}\}}}|jd ks|j|krtjj	dj
| |jrtjj	dj
| tjj	dj
| |d7 }qW |jsF|r:tjj	dj
| ntjj	d d S )Nr   zSerial port enumeration)descriptionr	   ?z%only show ports that match this regex)nargshelpz-vz	--verbose
store_truezshow more messages)actionr   z-qz--quietzsuppress all messagesz-nzonly output the N-th entry)typer   z Filtered list with regexp: {!r}
   z{:20}
z    desc: {}
z    hwid: {}
z{} ports found
zno ports found
)argparseArgumentParseradd_argumentint
parse_argsr	   quietsysstderrwriteformatsortedr   r   	enumeratenstdoutverbose)	r   parserargshitsiteratorr&   r   r   r   r   r   r   main3   sH    
r-   __main__)__doc__r    osr   nameZserial.tools.list_ports_windowsr   Zserial.tools.list_ports_posixImportErrorr#   r   r-   __name__r   r   r   r   <module>   s   

3