o
    - h                  
   @   s   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dZ	
	
ddeeef dededee
 fd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                 C   sJ   t | tst | tstdt|  t| } t|d}||  | 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   detector r   X/var/www/html/figdemos/bartoux_crm/venv/lib/python3.10/site-packages/chardet/__init__.pyr      s   



r   ignore_thresholdc           	      C   s4  t | tst | tstdt|  t| } t|d}||  |  |jt	j
krg }g }|jD ]}t |trE|dd |jD  q2|| q2|D ]:}|sX| |jkr|jp\d}| }|drp|jrp|j||}|r{|j| |}||| |jd qMt|dkrt|d	d
 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                 s   s    | ]}|V  qd S )Nr   ).0pr   r   r   	<genexpr>W   s    zdetect_all.<locals>.<genexpr> ziso-8859)encoding
confidencelanguager   c                 S   s
   | d  S )Nr#   r   )resultr   r   r   <lambda>q   s   
 zdetect_all.<locals>.<lambda>)key)r   r   r   r   r   r	   r   r   Zinput_stater   Z	HIGH_BYTEZcharset_probersr   extendprobersappendZget_confidenceZMINIMUM_THRESHOLDcharset_namelower
startswithZhas_win_bytesZISO_WIN_MAPgetZ
LEGACY_MAPr$   lensortedr%   )	r   r   r   r   resultsr)   Zproberr+   Zlower_charset_namer   r   r   r   5   sL   






r   N)F)FF)typingr   r   Zcharsetgroupproberr   Zcharsetproberr   enumsr   Z
resultdictr   Zuniversaldetectorr	   versionr
   r   __all__r   r   boolr   r   r   r   r   r   <module>   s6   


