U
    œ™WWÉ  ã                   @   s\   zd dl Z W n  ek
r,   d dlmZ  Y nX d dlZdd„ ZedkrXe d¡Ze	eƒ dS )é    Nc              
   C   sð   t  | ¡}|jdkr&t d |j¡¡‚d}z@t  |jd¡ ¡ D ](\}}|dkrX|d }q>t	d |¡ƒ‚q>W n2 t	k
rœ } zt d |¡¡‚W 5 d	}~X Y nX t
t|ƒs¶t	d
 |¡ƒ‚tt|ƒ}t|tjƒsÚt	d |¡ƒ‚d |j|jg¡|fS )z(extract host and port from an URL stringZaltzmexpected a string in the form "alt://port[?option[=value][&option[=value]]]": not starting with alt:// ({!r})ÚSerialTÚclassr   zunknown option: {!r}zRexpected a string in the form "alt://port[?option[=value][&option[=value]]]": {!r}Nzunknown class: {!r}z'class {!r} is not an instance of SerialÚ )ÚurlparseZurlsplitZschemeÚserialZSerialExceptionÚformatZparse_qsZqueryÚitemsÚ
ValueErrorÚhasattrÚgetattrÚ
issubclassr   ÚjoinZnetlocÚpath)ZurlÚpartsÚ
class_nameZoptionÚvaluesÚeÚcls© r   ú@/usr/lib/python3/dist-packages/serial/urlhandler/protocol_alt.pyÚserial_class_for_url   s2    

ÿÿ
ÿÿ

r   Ú__main__z&alt:///dev/ttyS0?class=PosixPollSerial)
r   ÚImportErrorZurllib.parseÚparser   r   Ú__name__Zserial_for_urlÚsÚprintr   r   r   r   Ú<module>   s   
