
$V&                 @   s   d  d l  Z  d  d l Z d  d l Td Z e j d k rJ d  d l m Z n d  d l Z e j d k rx d  d l	 m Z nf e j d k r d  d l
 m Z m Z m Z n8 e j d	 k r d  d l m Z n e d
 e j f   d g Z d d   Z d S)    N)*z3.0.1Zcli)Serialntposix)r   PosixPollSerialVTIMESerialjavaz;Sorry: no implementation for your platform ('%s') availablezserial.urlhandlerc             O   s.  | j  d d  } t } y |  j   } Wn t k
 r= Yn Xd | k r | j d d  d } d | f } x t D]t } y% t j |  }	 t j | |  }
 Wn t k
 r wt Yqt Xt	 |
 d  r |
 j
 |   \ }  } n	 |
 j } Pqt Wt d | f   | d	 | |  } |  | _ | r*| j   | S)
a      Get an instance of the Serial class, depending on port/url. The port is not
    opened when the keyword parameter 'do_not_open' is true, by default it
    is. All other parameters are directly passed to the __init__ method when
    the port is instantiated.

    The list of package names that is searched for protocol handlers is kept in
    ``protocol_handler_packages``.

    e.g. we want to support a URL ``foobar://``. A module
    ``my_handlers.protocol_foobar`` is provided by the user. Then
    ``protocol_handler_packages.append("my_handlers")`` would extend the search
    path so that ``serial_for_url("foobar://"))`` would work.
    Zdo_not_openFz://   r   z.protocol_%sserial_class_for_urlz"invalid URL, protocol %r not knownN)popr   lowerAttributeErrorsplitprotocol_handler_packages	importlibimport_moduleImportErrorhasattrr
   
ValueErrorZportopen)ZurlargskwargsZdo_openklassZurl_lowercaseZprotocolZmodule_nameZpackage_namepackageZhandler_moduleinstance r   1/usr/lib/python3/dist-packages/serial/__init__.pyserial_for_url&   s2    		
r   )r   sysZserial.serialutilVERSIONplatformZserial.serialclir   osnameZserial.serialwin32Zserial.serialposixr   r   Zserial.serialjavar   r   r   r   r   r   r   <module>
   s   
	