a
    hbòfÇ  ã                   @   sD   d dl mZ d dlmZ d dlmZmZ g d¢Zdd„ Zdd„ Z	d	S )
é   )ÚUniversalDetector)Ú
InputState)Ú__version__ÚVERSION)r   ÚdetectÚ
detect_allr   r   c                 C   sH   t | tƒs0t | tƒs(td t| ƒ¡ƒ‚nt| ƒ} tƒ }| | ¡ | ¡ S )z£
    Detect the encoding of the given byte string.

    :param byte_str:     The byte sequence to examine.
    :type byte_str:      ``bytes`` or ``bytearray``
    ú3Expected object of type bytes or bytearray, got: {})	Ú
isinstanceÚ	bytearrayÚbytesÚ	TypeErrorÚformatÚtyper   ÚfeedÚclose)Úbyte_strÚdetector© r   úY/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/pip/_vendor/chardet/__init__.pyr      s    

ÿ
r   c                 C   sÜ   t | tƒs0t | tƒs(td t| ƒ¡ƒ‚nt| ƒ} tƒ }| | ¡ | ¡  |j	t
jkrÔg }|jD ]X}| ¡ |jkr^|j}|j ¡ }| d¡rž|jrž|j ||¡}| || ¡ |jdœ¡ q^t|ƒdkrÔt|dd„ d�S |jgS )z±
    Detect all the possible encodings of the given byte string.

    :param byte_str:     The byte sequence to examine.
    :type byte_str:      ``bytes`` or ``bytearray``
    r   ziso-8859)ÚencodingÚ
confidenceÚlanguageé    c                 S   s
   | d  S )Nr   r   )Úresultr   r   r   Ú<lambda>Q   ó    zdetect_all.<locals>.<lambda>)Úkey)r	   r
   r   r   r   r   r   r   r   Ú_input_stater   Ú	HIGH_BYTEÚ_charset_probersÚget_confidenceÚMINIMUM_THRESHOLDÚcharset_nameÚlowerÚ
startswithÚ_has_win_bytesÚISO_WIN_MAPÚgetÚappendr   ÚlenÚsortedr   )r   r   ÚresultsÚproberr"   Úlower_charset_namer   r   r   r   -   s8    

ÿ



ÿý
r   N)
Úuniversaldetectorr   Úenumsr   Úversionr   r   Ú__all__r   r   r   r   r   r   Ú<module>   s
   