3
[                 @   s   d dl mZmZmZmZmZ ddlZddlZejdZ	G dd dej
Z
G dd dejZG d	d
 d
ejZG dd de
ejZG dd de
ejZdd ZdS )   )encodedecodealabelulabel	IDNAError    Nu   [.。．｡]c               @   s    e Zd ZdddZdddZdS )	Codecstrictc             C   s.   |dkrt dj||sdS t|t|fS )Nr	   z Unsupported error handling "{0}" r   )r
   r   )r   formatr   len)selfdataerrors r   7/tmp/pip-install-65viz3iy/pip/pip/_vendor/idna/codec.pyr   	   s
    zCodec.encodec             C   s.   |dkrt dj||sdS t|t|fS )Nr	   z Unsupported error handling "{0}"r
   r   )r
   r   )r   r   r   r   )r   r   r   r   r   r   r      s
    zCodec.decodeN)r	   )r	   )__name__
__module____qualname__r   r   r   r   r   r   r      s   

r   c               @   s   e Zd Zdd ZdS )IncrementalEncoderc       	      C   s   |dkrt dj||sdS tj|}d}|rV|d sDd}|d	= n|sV|d
= |rVd}g }d}x2|D ]*}|jt| |r|d7 }|t|7 }qdW dj|| }|t|7 }||fS )Nr	   z Unsupported error handling "{0}"r
   r   r   .)r
   r   r   r   )r   r   _unicode_dots_resplitappendr   r   join)	r   r   r   finallabelstrailing_dotresultsizelabelr   r   r   _buffer_encode   s0    

z!IncrementalEncoder._buffer_encodeN)r   r   r   r"   r   r   r   r   r      s   r   c               @   s   e Zd Zdd ZdS )IncrementalDecoderc       	      C   s   |dkrt dj||sdS t|tr4tj|}nt|}t|d |jd}d}|r~|d	 sld}|d
= n|s~|d= |r~d}g }d}x2|D ]*}|jt| |r|d7 }|t	|7 }qW dj
|| }|t	|7 }||fS )Nr	   z Unsupported error handling "{0}"r
   r   asciir   r   )r
   r   r   r   r   )r   r   
isinstanceunicoder   r   strr   r   r   r   )	r   r   r   r   r   r   r   r    r!   r   r   r   _buffer_decode?   s8    



z!IncrementalDecoder._buffer_decodeN)r   r   r   r(   r   r   r   r   r#   >   s   r#   c               @   s   e Zd ZdS )StreamWriterN)r   r   r   r   r   r   r   r)   g   s   r)   c               @   s   e Zd ZdS )StreamReaderN)r   r   r   r   r   r   r   r*   j   s   r*   c            	   C   s    t jdt jt jttttdS )Nidna)namer   r   incrementalencoderincrementaldecoderstreamwriterstreamreader)	codecs	CodecInfor   r   r   r   r#   r)   r*   r   r   r   r   getregentrym   s    r3   )corer   r   r   r   r   r1   recompiler   r   BufferedIncrementalEncoderr   BufferedIncrementalDecoderr#   r)   r*   r3   r   r   r   r   <module>   s   
!)