a
    Bù’in  ã                   @   sÌ   d dl Z d dlZd dlmZmZmZ ddlmZmZm	Z	m
Z
mZ e 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eee j dœdd„Ze  e¡ dS )é    N)ÚAnyÚOptionalÚTupleé   )Ú	IDNAErrorÚalabelÚdecodeÚencodeÚulabelu   [.ã€‚ï¼Žï½¡]c                   @   sD   e Zd Zdeeeeef dœdd„Zd	eeeeef dœdd„ZdS )
ÚCodecÚstrict)ÚdataÚerrorsÚreturnc                 C   s.   |dkrt d |¡ƒ‚|sdS t|ƒt|ƒfS )Nr   úUnsupported error handling "{}"©ó    r   )r   Úformatr	   Úlen©Úselfr   r   © r   úG/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/idna/codec.pyr	      s
    zCodec.encodec                 C   s.   |dkrt d |¡ƒ‚|sdS t|ƒt|ƒfS )Nr   r   ©Ú r   )r   r   r   r   r   r   r   r   r      s
    zCodec.decodeN)r   )r   )	Ú__name__Ú
__module__Ú__qualname__Ústrr   ÚbytesÚintr	   r   r   r   r   r   r   
   s   	r   c                   @   s(   e Zd Zeeeeeef dœdd„ZdS )ÚIncrementalEncoder©r   r   Úfinalr   c           
      C   s°   |dkrt d |¡ƒ‚|sdS t |¡}d}|rV|d sDd}|d= n|sV|d= |rVd}g }d}|D ]*}| t|ƒ¡ |r€|d7 }|t|ƒ7 }qbd |¡| }	|t|ƒ7 }|	|fS )	Nr   r   r   r   éÿÿÿÿó   .r   r   )r   r   Ú_unicode_dots_reÚsplitÚappendr   r   Újoin)
r   r   r   r#   ÚlabelsÚtrailing_dotÚresultÚsizeÚlabelZresult_bytesr   r   r   Ú_buffer_encode   s0    
z!IncrementalEncoder._buffer_encodeN)	r   r   r   r   Úboolr   r   r    r/   r   r   r   r   r!      s   r!   c                   @   s(   e Zd Zeeeeeef dœdd„ZdS )ÚIncrementalDecoderr"   c           
      C   sÄ   |dkrt d |¡ƒ‚|sdS t|tƒs2t|dƒ}t |¡}d}|rj|d sXd}|d= n|sj|d= |rjd}g }d}|D ]*}| t|ƒ¡ |r”|d	7 }|t|ƒ7 }qvd 	|¡| }	|t|ƒ7 }|	|fS )
Nr   r   r   Úasciir   r$   Ú.r   r   )
r   r   Ú
isinstancer   r&   r'   r(   r
   r   r)   )
r   r   r   r#   r*   r+   r,   r-   r.   Z
result_strr   r   r   Ú_buffer_decodeA   s4    


z!IncrementalDecoder._buffer_decodeN)	r   r   r   r   r   r0   r   r    r5   r   r   r   r   r1   @   s   r1   c                   @   s   e Zd ZdS )ÚStreamWriterN©r   r   r   r   r   r   r   r6   d   s   r6   c                   @   s   e Zd ZdS )ÚStreamReaderNr7   r   r   r   r   r8   h   s   r8   )Únamer   c              	   C   s,   | dkrd S t j| tƒ jtƒ jttttd�S )NZidna2008)r9   r	   r   ÚincrementalencoderÚincrementaldecoderÚstreamwriterÚstreamreader)	ÚcodecsÚ	CodecInfor   r	   r   r!   r1   r6   r8   )r9   r   r   r   Úsearch_functionl   s    ùr@   )r>   ÚreÚtypingr   r   r   Úcorer   r   r   r	   r
   Úcompiler&   r   ÚBufferedIncrementalEncoderr!   ÚBufferedIncrementalDecoderr1   r6   r8   r   r?   r@   Úregisterr   r   r   r   Ú<module>   s   
"$