OwlCyberSecurity - MANAGER
Edit File: __init__.cpython-39.pyc
a (��e� � @ s� d dl mZmZ ddlmZ ddlmZ ddlmZ ddl m Z ddlmZ ddl mZmZ g d �Zdeeef ee d�dd �Zdeeef eeee d�dd�ZdS )� )�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&tdt| �� ���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 �]/home/gouroczh/virtualenv/pat/3.9/lib/python3.9/site-packages/pip/_vendor/chardet/__init__.pyr s � r )r �ignore_thresholdr r c C s8 t | t�s.t | t�s&tdt| �� ���t| �} t|d�}|�| � |�� |jt j k�r0g }g }|jD ]0}t |t�r�|� dd� |jD �� qf|�|� qf|D ]t}|s�|�� |jkr�|jp�d}|�� }|�d�r�|jr�|j�||�}|r�|j�|�� |�}|�||�� |jd�� q�t|�dk�r0t|d d � d�S |jgS )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 qd S )Nr )�.0�pr r r � <genexpr>W � zdetect_all.<locals>.<genexpr>� ziso-8859)�encoding� confidence�languager c S s | d S )Nr$ r )�resultr r r �<lambda>q r! zdetect_all.<locals>.<lambda>)�key)r r r r r r r r Zinput_stater Z HIGH_BYTEZcharset_probersr �extend�probers�appendZget_confidenceZMINIMUM_THRESHOLD�charset_name�lower� startswithZ has_win_bytesZISO_WIN_MAP�getZ LEGACY_MAPr% �len�sortedr&