03
  "   -laCl
f@*bѿbs     -#! python
#
# Python Serial Port Extension for Win32, Linux, BSD, Jython
# see __init__.py
#
# This module implements a special URL handler that uses the port listing to
# find ports by searching the string descriptions.
#
# (C) 2011 Chris Liechti <cliechti@gmx.net>
# this is distributed under a free software license, see license.txt
#
# URL format:    hwgrep://regexp

import serial
import serial.tools.list_ports

class Serial(serial.Serial):
    """Just inherit the native Serial port implementation and patch the open function."""

    def setPort(self, value):
        """translate port name before storing it"""
        if isinstance(value, basestring) and value.startswith('hwgrep://'):
            serial.Serial.setPort(self, self.fromURL(value))
        else:
            serial.Serial.setPort(self, value)

    def fromURL(self, url):
        """extract host and port from an URL string"""
        if url.lower().startswith("hwgrep://"): url = url[9:]
        # use a for loop to get the 1st element from the generator
        for port, desc, hwid in serial.tools.list_ports.grep(url):
            return port
        else:
            raise serial.SerialException('no ports found matching regexp %r' % (url,))

    # override property
    port = property(serial.Serial.getPort, setPort, doc="Port setting")

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if __name__ == '__main__':
    #~ s = Serial('hwgrep://ttyS0')
    s = Serial(None)
    s.port = 'hwgrep://ttyS0'
    print s

     /3 [    /
!ic           @   so   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z m Z m	 Z	 d e j
 f d     YZ d S(	   sI   Fixer for apply().

This converts apply(func, v, k) into (func)(*v, **k).i   (   t   pytree(   t   token(   t
   fixer_base(   t   Callt   Commat   parenthesizet   FixApplyc           B   s   e  Z e Z d  Z d   Z RS(   s.  
    power< 'apply'
        trailer<
            '('
            arglist<
                (not argument<NAME '=' any>) func=any ','
                (not argument<NAME '=' any>) args=any [','
                (not argument<NAME '=' any>) kwds=any] [',']
            >
            ')'
        >
    >
    c   	      C   sV  |  j  } | s t  | d } | d } | j d  } | j } | j   } | j t j | j f k r | j | j	 k s | j
 d j t j k r t |  } n  d | _ | j   } d | _ | d  k	 r | j   } d | _ n  t j t j d  | g } | d  k	 rC| j t   t j t j d  | g  d | d _ n  t | | d	 | S(
   Nt   funct   argst   kwdsit    u   *u   **u    t   prefix(   t   symst   AssertionErrort   getR   t   clonet   typeR   t   NAMEt   atomt   powert   childrent
   DOUBLESTARR   t   NoneR    t   Leaft   STARt   extendR   R   (	   t   selft   nodet   resultsR   R   R   R	   R   t	   l_newargs(    (    s/   /usr/lib64/python2.7/lib2to3/fixes/fix_apply.pyt	   transform   s0    	

			
(   t   __name__t
   __module__t   Truet   BM_compatiblet   PATTERNR   (    (    (    s/   /usr/lib64/python2.7/lib2to3/fixes/fix_apply.pyR      s   N(   t   __doc__R
   R    t   pgen2R   R   t
   fixer_utilR   R   R   t   BaseFixR   (    (    (    s/   /usr/lib64/python2.7/lib2to3/fixes/fix_apply.pyt   <module>   s
     $   1li~*eJq@;pM\i1hl { ?     1ELF          >    U@     @       (Y         @ 8 	 @         @       @ @     @ @                              8      8@     8@                                          @       @     t     t                   }     }v     }v     f      3                   }     }v     }v                                T      T@     T@     D       D              Ptd        S     S     4U      4U             Qtd                                                  Rtd   }     }v     }v         