
    Ofc                     B    d dl mZ d dlmZ d dlmZmZ g dZd Zd Z	dS )   )UniversalDetector)
InputState)__version__VERSION)r   detect
detect_allr   r   c                 @   t          | t                    sSt          | t                    s/t          d                    t          |                               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detectors     0lib/python3.11/site-packages/chardet/__init__.pyr   r      s     h	** +(E** 	+ !!'X!7!79 9 9 !**H ""HMM(>>    c                 $   t          | t                    sSt          | t                    s/t          d                    t          |                               t          |           } t                      }|                    |            |                                 |j	        t          j        k    rg }|j        D ]}|                                |j        k    r|j        }|j                                        }|                    d          r"|j        r|j                            ||          }|                    ||                                |j        d           t/          |          dk    rt1          |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                     | d          S )Nr    )results    r   <lambda>zdetect_all.<locals>.<lambda>Q   s    vl7K6K r   )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_names         r   r   r   -   s    h	** +(E** 	+ !!'X!7!79 9 9 !**H ""HMM(NN
 44 M/ 	 	F$$&&)CC %2%+%8%>%>%@%@" &00<< J. J'/';'?'?@R<H(J (J ,"("7"7"9"9 &      
 w<<! 	M''K'KLLLLOr   N)
universaldetectorr   enumsr   versionr   r   __all__r   r   r   r   r   <module>r6      sy   & 1 0 0 0 0 0       ) ) ) ) ) ) ) ) R
Q
Q  $& & & & &r   