U
    [e                     @   sJ   d dl mZ d dlmZ d dlmZmZ dddddgZd	d Zd
d Z	dS )   )UniversalDetector)
InputState)__version__VERSIONr   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   R/var/www/html/services/stratfitenv/lib/python3.8/site-packages/chardet/__init__.pyr      s    


c                 C   s   t | ts0t | ts(tdt| nt| } t }||  |  |j	t
jkrg }|jD ]X}| |jkr^|j}|j }|dr|jr|j||}||| |jd q^t|dkrt|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    






N)
universaldetectorr   enumsr   versionr   r   __all__r   r   r   r   r   r   <module>   s
   