3
ûâde}  ã               @   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   ú5/tmp/pip-build-red6nood/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 "{}"Ú 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   
""