a
     ˜ëj½  ã                   @   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eeef ee
dœdd„Zdeeef eeee
 dœ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   úO/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/chardet/__init__.pyr      s    

ÿ

r   )r   Úignore_thresholdr   r   c           	      C   s8  t | tƒs.t | tƒs&tdt| ƒ› �ƒ‚t| ƒ} t|d�}| | ¡ | ¡  |jt	j
k�r0g }g }|jD ]0}t |tƒrŒ| dd„ |jD ƒ¡ qf| |¡ qf|D ]t}|s²| ¡ |jkrœ|jpºd}| ¡ }| d¡râ|jrâ|j ||¡}|rø|j | ¡ |¡}| || ¡ |jdœ¡ qœt|ƒdk�r0t|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   ó    zdetect_all.<locals>.<genexpr>Ú ziso-8859)ÚencodingÚ
confidenceÚlanguager   c                 S   s
   | d  S )Nr$   r   )Úresultr   r   r   Ú<lambda>q   r!   zdetect_all.<locals>.<lambda>)Úkey)r   r   r   r   r   r	   r   r   Zinput_stater   Ú	HIGH_BYTEZcharset_probersr   ÚextendÚprobersÚappendÚget_confidenceÚMINIMUM_THRESHOLDÚcharset_nameÚlowerÚ
startswithZhas_win_bytesÚISO_WIN_MAPÚgetZ
LEGACY_MAPr%   ÚlenÚsortedr&   )	r   r   r   r   Úresultsr+   Úproberr/   Úlower_charset_namer   r   r   r   5   sJ    

ÿ




ÿÿýÿr   N)F)FF)Útypingr   r   Úcharsetgroupproberr   Úcharsetproberr   Úenumsr   Z
resultdictr   Úuniversaldetectorr	   Úversionr
   r   Ú__all__r   r   Úboolr   r   r   r   r   r   Ú<module>   s(    ÿþ  ý
ü