
    Ng              
           d dl mZmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZmZ g d	Z	 ddeeef         dede
fdZ	 	 ddeeef         dededee
         fdZdS )    )ListUnion   )CharSetGroupProber)CharSetProber)
InputState)
ResultDict)UniversalDetector)VERSION__version__)r
   detect
detect_allr   r   Fbyte_strshould_rename_legacyreturnc                 $   t          | t                    sCt          | t                    st          dt	          |                      t          |           } t          |          }|                    |            |                                S )aV  
    Detect the encoding of the given byte string.

    :param byte_str:     The byte sequence to examine.
    :type byte_str:      ``bytes`` or ``bytearray``
    :param should_rename_legacy:  Should we rename legacy encodings
                                  to their more modern equivalents?
    :type should_rename_legacy:   ``bool``
    1Expected object of type bytes or bytearray, got: r   )
isinstance	bytearraybytes	TypeErrortyper
   feedclose)r   r   detectors      L/var/www/html/ai-engine/env/lib/python3.11/site-packages/chardet/__init__.pyr   r      s     h	** '(E** 	TDNNTT   X&& 6JKKKHMM(>>    ignore_thresholdc                    t          | t                    sCt          | t                    st          dt	          |                      t          |           } t          |          }|                    |            |                                 |j        t          j
        k    rYg }g }|j        D ]Q}t          |t                    r%|                    d |j        D                        <|                    |           R|D ]}|s|                                |j        k    r|j        pd}|                                }|                    d          r"|j        r|j                            ||          }|r-|j                            |                                |          }|                    ||                                |j        d           t5          |          dk    rt7          |d 	          S |j        gS )
aD  
    Detect all the possible encodings of the given byte string.

    :param byte_str:          The byte sequence to examine.
    :type byte_str:           ``bytes`` or ``bytearray``
    :param ignore_threshold:  Include encodings that are below
                              ``UniversalDetector.MINIMUM_THRESHOLD``
                              in results.
    :type ignore_threshold:   ``bool``
    :param should_rename_legacy:  Should we rename legacy encodings
                                  to their more modern equivalents?
    :type should_rename_legacy:   ``bool``
    r   r   c              3      K   | ]}|V  d S )N ).0ps     r   	<genexpr>zdetect_all.<locals>.<genexpr>W   s"      99Qq999999r    ziso-8859)encoding
confidencelanguager   c                     | d          S )Nr(   r"   )results    r   <lambda>zdetect_all.<locals>.<lambda>q   s    vl7K6K r   )key)r   r   r   r   r   r
   r   r   input_stater   	HIGH_BYTEcharset_probersr   extendprobersappendget_confidenceMINIMUM_THRESHOLDcharset_namelower
startswithhas_win_bytesISO_WIN_MAPget
LEGACY_MAPr)   lensortedr+   )	r   r   r   r   resultsr2   proberr6   lower_charset_names	            r   r   r   5   s8   $ h	** '(E** 	TDNNTT   X&& 6JKKKHMM(NNz333$&'). 	' 	'F&"455 '99&.9999999v&&&& 	 	F 6#8#8#:#:X=W#W#W%28b%1%7%7%9%9" &00<< AW #+#7#;#;*L$ $L ( #+#6#:#:$**,,l$ $L $0&,&;&;&=&=$*O    w<<!''K'KLLLLOr   N)F)FF)typingr   r   charsetgroupproberr   charsetproberr   enumsr   
resultdictr	   universaldetectorr
   versionr   r   __all__r   r   boolr   r   r"   r   r   <module>rK      s<  $         2 2 2 2 2 2 ( ( ( ( ( (       " " " " " " 0 0 0 0 0 0 ) ) ) ) ) ) ) )
Q
Q
Q EJ E9$%=A   2 #!&> >E9$%>> > 
*	> > > > > >r   