Your IP : 3.138.34.93


Current Path : /opt/alt/python310/lib64/python3.10/encodings/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/encodings/__pycache__/punycode.cpython-310.pyc

o

6��f��@s�dZddlZdd�Zdd�Zdd�Zd	d
�Zdd�Zd
Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZGdd�dej�ZGdd�dej�ZGd d!�d!ej�ZGd"d#�d#eej�ZGd$d%�d%eej�Zd&d'�ZdS)(uY Codec for the Punicode encoding, as specified in RFC 3492

Written by Martin v. Löwis.
�NcCsPt�}t�}|D]}t|�dkr|�t|��q|�|�qt|�}t|�|fS)z 3.1 Basic code point segregation�)�	bytearray�set�ord�append�add�sorted�bytes)�str�base�extended�c�r�9/opt/alt/python310/lib64/python3.10/encodings/punycode.py�	segregate
srcCs&d}|D]}t|�|kr|d7}q|S)z@Return the length of str, considering only characters below max.r�)r)r
�max�resr
rrr�
selective_lens�rcCsLt|�}	|d7}||krdS||}||kr|d|fS||kr%|d7}q)aReturn a pair (index, pos), indicating the next occurrence of
    char in str. index is the position of the character considering
    only ordinals up to and including char, and pos is the position in
    the full string. index/pos is the starting position in the full
    string.r)���r)�len)r
�char�index�pos�lr
rrr�selective_finds�rcCs�d}g}d}|D]:}d}}t|�}t||�}	|	d||}
	t||||�\}}|dkr.n|
||7}
|�|
d�|}d}
q |}q|S)�3.2 Insertion unsort codingrrrr)rrrr)r
rZoldchar�resultZoldindexr
rrrZcurlen�deltarrr�insertion_unsort0s&
�rcCs,d|d|}|dkrdS|dkrdS|S)N�$r�r)�j�biasrrrr�TFsr$s$abcdefghijklmnopqrstuvwxyz0123456789cCslt�}d}	t||�}||kr|�t|�t|�S|�t|||d|�||d|}|d7}q)�(3.3 Generalized variable-length integersrrr )rr$r�digitsr	)�Nr#rr"�trrr�generate_generalized_integerNs
�r)cCs^|r|d}n|d}|||7}d}|dkr#|d}|d7}|dks|d||d}|S)Ni��ri��#r �&r)r�first�numcharsZ	divisionsr#rrr�adapt[s
�r/cCsPt�}d}t|�D]\}}t||�}|�|�t||dk||d�}q	t|�S)z3.4 Bias adaptation�Hrr)r�	enumerater)�extendr/r	)Zbaselen�deltasrr#Zpointsr�srrr�generate_integersjs

r5cCs8t|�\}}t||�}tt|�|�}|r|d|S|S)N�-)rrr5r)�textrrr3rrr�punycode_encodeus
r8c
Cs�d}d}d}	zt||�}Wnty&|dkrtd��|ddfYSw|d7}d|kr5dkr<nn|d}n#d|krFd	krMnn|d
}n|dkr[td||d��|dfSt||�}	|||7}||	krr||fS|d|	}|d7}q)
r%rr�strictzincomplete punicode stringN�A�Z�0�9�z Invalid extended code point '%s'r )r�
IndexError�UnicodeErrorr$)
r�extposr#�errorsr�wr"rZdigitr(rrr�decode_generalized_numbers8�


�
�rDc	Cs�d}d}d}d}|t|�krit||||�\}}|dur|S||d7}||t|�d7}|dkr?|dkr;td	|��td
�}|t|�d}|d|�t|�||d�}t||dkt|��}|}|t|�ks|S)rrrr0rNri��r9zInvalid character U+%x�?)rrDr@r�chrr/)	rrrBrrr#rAZnewposrrrr�insertion_sort�s,� �rGcCs�t|t�r
|�d�}t|t�rt|�}|�d�}|dkr&d}t|d���}nt|d|�d|�}t||dd�d���}t|||�S)N�asciir6r�r)�
isinstancer
�encode�
memoryviewr	�rfind�upperrG)r7rBrrrrrr�punycode_decode�s



rOc@s eZdZddd�Zddd�ZdS)�Codecr9cCst|�}|t|�fS�N)r8r��self�inputrBrrrrrK�szCodec.encodecCs*|dvr
td|��t||�}|t|�fS�N)r9�replace�ignorezUnsupported error handling )r@rOrrRrrr�decode�s
zCodec.decodeN)r9)�__name__�
__module__�__qualname__rKrXrrrrrP�s
rPc@�eZdZddd�ZdS)�IncrementalEncoderFcCst|�SrQ)r8�rSrT�finalrrrrK�szIncrementalEncoder.encodeN�F)rYrZr[rKrrrrr]��r]c@r\)�IncrementalDecoderFcCs$|jdvrtd|j��t||j�SrU)rBr@rOr^rrrrX�s
zIncrementalDecoder.decodeNr`)rYrZr[rXrrrrrb�rarbc@�eZdZdS)�StreamWriterN�rYrZr[rrrrrd��rdc@rc)�StreamReaderNrerrrrrg�rfrgc	Cs tjdt�jt�jttttd�S)NZpunycode)�namerKrX�incrementalencoder�incrementaldecoder�streamwriter�streamreader)	�codecs�	CodecInforPrKrXr]rbrdrgrrrr�getregentry�s�ro)�__doc__rmrrrrr$r&r)r/r5r8rDrGrOrPr]rbrdrgrorrrr�<module>s*



?>