o
    l¨Êh  ã                   @   sr   z	d dl mZ W dS  ey8   d dlmZmZ d dlZd dlm	Z	mZ e 
d¡Zdd„ Zdd	„ Zd
d„ ZY dS w )é    )Úopen)ÚlookupÚBOM_UTF8N)ÚTextIOWrapperr   zcoding[:=]\s*([-\w.]+)c                 C   sH   | dd…   ¡  dd¡}|dks| d¡rdS |dv s | d¡r"d	S | S )
z(Imitates get_normal_name in tokenizer.c.Né   Ú_ú-úutf-8zutf-8-)zlatin-1ú
iso-8859-1ziso-latin-1)zlatin-1-ziso-8859-1-ziso-latin-1-r
   )ÚlowerÚreplaceÚ
startswith)Úorig_encÚenc© r   úH/var/www/html/env/lib/python3.10/site-packages/joblib/_memory_helpers.pyÚ_get_normal_name   s   ÿr   c                    s¢   d‰ d}d}‡fdd„}‡ fdd„}|ƒ }|  t¡r$d‰ |d	d… }d
}|s*|g fS ||ƒ}|r5||gfS |ƒ }|s?||gfS ||ƒ}|rK|||gfS |||gfS )aF  
        The detect_encoding() function is used to detect the encoding that
        should be used to decode a Python source file.  It requires one
        argment, readline, in the same way as the tokenize() generator.

        It will call readline a maximum of twice, and return the encoding used
        (as a string) and a list of any lines (left as bytes) it has read in.

        It detects the encoding from the presence of a utf-8 bom or an encoding
        cookie as specified in pep-0263.  If both a bom and a cookie are
        present, but disagree, a SyntaxError will be raised.  If the encoding
        cookie is an invalid charset, raise a SyntaxError.  Note that if a
        utf-8 bom is found, 'utf-8-sig' is returned.

        If no encoding is specified, then the default of 'utf-8' will be
        returned.
        FNr	   c                      s   zˆ ƒ W S  t y   Y dS w )Nó    )ÚStopIterationr   )Úreadliner   r   Úread_or_stop-   s
   ÿz&_detect_encoding.<locals>.read_or_stopc                    sŒ   z|   d¡}W n
 ty   Y d S w t |¡}|sd S t|d ƒ}zt|ƒ}W n ty4   td| ƒ‚w ˆ rD|jdkr@tdƒ‚|d7 }|S )NÚasciir   zunknown encoding: r	   zencoding problem: utf-8z-sig)	ÚdecodeÚUnicodeDecodeErrorÚ	cookie_reÚfindallr   r   ÚLookupErrorÚSyntaxErrorÚname)ÚlineÚline_stringÚmatchesÚencodingÚcodec)Ú	bom_foundr   r   Úfind_cookie3   s&   ÿ
þ
z%_detect_encoding.<locals>.find_cookieTé   z	utf-8-sig)r   r   )r   r"   Údefaultr   r%   ÚfirstÚsecondr   )r$   r   r   Ú_detect_encoding   s,   


r*   c                 C   s:   t | dƒ}t|jƒ\}}| d¡ t||dd�}d|_|S )z`Open a file in read only mode using the encoding detected by
        detect_encoding().
        Úrbr   T)Úline_bufferingÚr)r   r*   r   Úseekr   Úmode)ÚfilenameÚbufferr"   ÚlinesÚtextr   r   r   Úopen_py_source`   s   

r4   )Útokenizer   r4   ÚImportErrorÚcodecsr   r   ÚreÚior   Úcompiler   r   r*   r   r   r   r   Ú<module>   s    
I¥