
    ^=                         d Z ddlmZ ddlZddlZddlZej                  dk(  rddlmZ n7ej                  dk(  rddl	mZ n! e
dj                  ej                              ddZd	 Zed
k(  r e        yy)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.
    )absolute_importNnt)comportsposixz;Sorry: no implementation for your platform ('{}') availablec              #      K   t        j                  | t         j                        }t        |      D ]@  }|\  }}}|j	                  |      s#|j	                  |      s|j	                  |      s=| B yw)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include_linksrinfoportdeschwids          9/usr/lib/python3/dist-packages/serial/tools/list_ports.pygrepr   '   s`      	

6244 A' dD88D>QXXd^qxx~Js   A,A6/A6c                     dd l } | j                  d      }|j                  ddd       |j                  dd	d
d       |j                  ddd
d       |j                  dt        d       |j                  ddd
d       |j	                         }d}|j
                  ro|j                  s8t        j                  j                  dj                  |j
                               t        t        |j
                  |j                              }nt        t        |j                              }t        |d      D ]  \  }\  }}}|j                   |j                   |k(  rt        j"                  j                  dj                  |             |j$                  r\t        j"                  j                  dj                  |             t        j"                  j                  dj                  |             |dz  } |j                  sQ|r/t        j                  j                  dj                  |             y t        j                  j                  d       y y )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-sz--include-linksz1include entries that are symlinks to real devicesz Filtered list with regexp: {!r}
)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   r   	enumeratenstdoutverbose)	r   parserargshitsiteratorr*   r   r   r   s	            r   mainr1   5   s
   $$1J$KF
4  6
 k!  #
 i$  &
 )  +
 @  B
 DD{{zzJJ@GGTU$t{{$:L:LMN(1C1CDE!*8Q!7 D$66>TVVq[JJY--d34||

  !1!8!8!>?

  !1!8!8!>?	 ::JJ/66t<=JJ/0	     __main__)F)__doc__
__future__r   r$   osr   nameserial.tools.list_ports_windowsr   serial.tools.list_ports_posixImportErrorr'   r   r1   __name__ r2   r   <module>r=      sv    ' 
 	 	
 77d?8WW6 SZZ[][b[bc
dd

41p zF r2   