<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
B
    ÍAÒ[Ñ  ã               @   s¼   d Z ddlZddlZddlmZ dZdd„ Zdd„ ZejrHe	Z
d	d
„ ZneZ
e	Zdd„ ZG dd„ deƒZdd„ Zdd„ Zdd„ Zdd„ ZdZedƒZedƒZe e¡jZdd„ Zedkr¸dS )z¾
This is Victor Stinner's pure-Python implementation of PEP 383: the "surrogateescape" error
handler of Python 3.

Source: misc/python/surrogateescape.py in https://bitbucket.org/haypo/misc
é    N)ÚutilsÚsurrogateescapec             C   s   t jr
| S |  d¡S d S )NZunicode_escape)r   ÚPY3Údecode)Útext© r   úM/opt/alt/python37/lib/python3.7/site-packages/future/utils/surrogateescape.pyÚu   s    r	   c             C   s   t jr|  d¡S | S d S )NÚlatin1)r   r   Úencode)Údatar   r   r   Úb   s    
r   c             C   s
   t | fƒS )N)Úbytes)Úcoder   r   r   Ú<lambda>#   ó    r   c             C   sf   | j | j| j… }y0t| tƒr(t|ƒ}nt| tƒr<t|ƒ}n| ‚W n tk
rZ   | ‚Y nX || jfS )zý
    Pure Python implementation of the PEP 383: the "surrogateescape" error
    handler of Python 3. Undecodable bytes will be replaced by a Unicode
    character U+DCxx on decoding, and these are translated into the
    original bytes on encoding.
    )	ÚobjectÚstartÚendÚ
isinstanceÚUnicodeDecodeErrorÚreplace_surrogate_decodeÚUnicodeEncodeErrorÚreplace_surrogate_encodeÚNotASurrogateError)ÚexcÚmystringÚdecodedr   r   r   Úsurrogateescape_handler(   s    




r   c               @   s   e Zd ZdS )r   N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   C   s   r   c             C   sŒ   g }xz| D ]r}t |ƒ}d|  kr*dks0n t‚d|  krDdkr\n n| t|d ƒ¡ q
|dkrx| t|d ƒ¡ q
t‚q
W tƒ  |¡S )zƒ
    Returns a (unicode) string, not the more logical bytes, because the codecs
    register_error functionality expects this.
    i Ø  iÿÜ  i Ü  iÜ  )Úordr   ÚappendÚ_unichrÚstrÚjoin)r   r   Úchr   r   r   r   r   G   s    
r   c             C   s~   g }xl| D ]d}t |tƒr|}nt|ƒ}d|  kr:dkrRn n| td| ƒ¡ q
|dkrj| t|ƒ¡ q
t‚q
W tƒ  |¡S )z$
    Returns a (unicode) string
    é€   éÿ   i Ü  é   )r   Úintr"   r#   r$   r   r%   r&   )Zmybytesr   r'   r   r   r   r   r   d   s    

r   c             C   sJ  t dkrŒg }xrt| ƒD ]f\}}t|ƒ}|dk r8t|ƒ}n:d|  krLdkr^n nt|d ƒ}ntt | ||d dƒ‚| |¡ qW tƒ  |¡S t dkr:g }x’t| ƒD ]†\}}t|ƒ}d	|  krÊd
krn nHd|  krädkr n nt|d ƒ}| |¡ ntt | ||d dƒ‚q¤| d¡}| |¡ q¤W tƒ  |¡S |  t t	¡S d S )NÚasciir(   i€Ü  iÿÜ  i Ü  é   zordinal not in range(128)zutf-8i Ø  iÿß  zsurrogates not allowed)
ÚFS_ENCODINGÚ	enumerater"   Ú	bytes_chrr   r#   r   r&   r   Ú	FS_ERRORS)ÚfnÚencodedÚindexr'   r   Zch_utf8r   r   r   Úencodefilename}   s8    



r5   c             C   s   |   tt¡S )N)r   r.   r1   )r2   r   r   r   Údecodefilename¤   s    r6   r,   u   [abcÃ¿]u   [abcí³¿]c               C   s>   t jr
dS yt t¡ W n  tk
r8   t tt¡ Y nX dS )zH
    Registers the surrogateescape error handler on Python 2 (only)
    N)r   r   ÚcodecsÚlookup_errorr1   ÚLookupErrorÚregister_errorr   r   r   r   r   Úregister_surrogateescape±   s    r;   Ú__main__)Ú__doc__r7   ÚsysZfuturer   r1   r	   r   r   Úchrr$   r0   Zunichrr   Ú	Exceptionr   r   r   r5   r6   r.   r2   r3   ÚlookupÚnamer;   r   r   r   r   r   Ú<module>   s0   
'  