3
Ug}                 @   s   d dl mZmZmZmZmZ ddlZddlZddlm	Z	m
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    N)TupleOptionalu   [.。．｡]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 "{}"    r   )r   r   )r   formatr   len)selfdataerrors r   :/tmp/pip-unpacked-wheel-0ht26j5g/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 "{}" 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 "{}"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label
result_strr   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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 "{}"r   r   r   r   )r   r   r   r   r   )r   r   r   r   r   r   r   r   )
r   r   r   r   r    r!   r"   r#   r$   r%   r   r   r   _buffer_decodeA   s0    

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)   b   s   r)   c               @   s   e Zd ZdS )StreamReaderN)r   r   r   r   r   r   r   r*   f   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   getregentryj   s    r3   )corer   r   r   r   r   r1   retypingr   r	   compiler   r
   BufferedIncrementalEncoderr   BufferedIncrementalDecoderr'   r)   r*   r3   r   r   r   r   <module>   s   
""