o
    j                     @  s   d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZ ddlmZ ddlmZ ddlmZmZ ddlmZmZ dd	lmZmZ dd
lmZ ddlmZmZ g dZdejeefdddddddd,d&d'Z ddejeefdddddddd-d*d+Z!dS ).u@   Universal character encoding detector — 0BSD-licensed rewrite.    )annotations)Iterable)_DEFAULT_CHUNK_SIZEDEFAULT_MAX_BYTESMINIMUM_THRESHOLD_resolve_prefer_superset_validate_max_bytes_warn_deprecated_chunk_size)__version__)UniversalDetector)EncodingEraLanguageFilter)apply_compat_namesapply_preferred_superset)DetectionDictDetectionResult)run_pipeline)_validate_encodingnormalize_encodings)
r   r   r   r   r   r   r   r
   detect
detect_allFTNcp1252zutf-8)prefer_supersetcompat_namesinclude_encodingsexclude_encodingsno_match_encodingempty_input_encodingbyte_strbytes | bytearrayshould_rename_legacyboolencoding_erar   
chunk_sizeint	max_bytesr   r   r   Iterable[str] | Noner   r   strr   returnr   c             	   C  s   t | t| t||}t|d}t|d}t|	d}t|
d}t| tr(| nt| }t|||||||d}|d  }|rCt	| |rIt
| |S )a  Detect the encoding of the given byte string.

    :param byte_str: The byte sequence to detect encoding for.
    :param should_rename_legacy: Deprecated alias for *prefer_superset*.
    :param encoding_era: Restrict candidate encodings to the given era.
    :param chunk_size: Deprecated -- accepted for backward compatibility but
        has no effect.
    :param max_bytes: Maximum number of bytes to examine from *byte_str*.
    :param prefer_superset: If ``True``, remap ISO subset encodings to their
        Windows/CP superset equivalents (e.g., ISO-8859-1 -> Windows-1252).
    :param compat_names: If ``True`` (default), return encoding names
        compatible with chardet 5.x/6.x.  If ``False``, return raw Python
        codec names.
    :param include_encodings: If given, restrict detection to only these
        encodings (names or aliases).
    :param exclude_encodings: If given, remove these encodings from the
        candidate set.
    :param no_match_encoding: Encoding to return when no candidate survives
        the pipeline.  Defaults to ``"cp1252"``.
    :param empty_input_encoding: Encoding to return for empty input.  Defaults
        to ``"utf-8"``.
    :returns: A dictionary with keys ``"encoding"``, ``"confidence"``, and
        ``"language"``.
    r   r   r   r   r%   r   r   r   r   r   )r	   r   r   r   r   
isinstancebytesr   to_dictr   r   )r   r    r"   r#   r%   r   r   r   r   r   r   includeexcludeno_matchemptydataresultsresult r4   V/var/www/html/fyndo/pharma/fyndo/venv/lib/python3.10/site-packages/chardet/__init__.pyr   %   s.   &




	r   ignore_thresholdlist[DetectionDict]c             	   C  s   t | t| t||}t|d}t|	d}t|
d}t|d}t| tr(| nt| }t|||||||d}dd |D }|sKdd |D }|rK|}|D ]}|rUt| |r[t	| qMt
|d	d
 ddS )aV  Detect all possible encodings of the given byte string.

    When *ignore_threshold* is False (the default), results with confidence
    <= MINIMUM_THRESHOLD (0.20) are filtered out.  If all results are below
    the threshold, the full unfiltered list is returned as a fallback so the
    caller always receives at least one result.

    :param byte_str: The byte sequence to detect encoding for.
    :param ignore_threshold: If ``True``, return all candidate encodings
        regardless of confidence score.
    :param should_rename_legacy: Deprecated alias for *prefer_superset*.
    :param encoding_era: Restrict candidate encodings to the given era.
    :param chunk_size: Deprecated -- accepted for backward compatibility but
        has no effect.
    :param max_bytes: Maximum number of bytes to examine from *byte_str*.
    :param prefer_superset: If ``True``, remap ISO subset encodings to their
        Windows/CP superset equivalents.
    :param compat_names: If ``True`` (default), return encoding names
        compatible with chardet 5.x/6.x.  If ``False``, return raw Python
        codec names.
    :param include_encodings: If given, restrict detection to only these
        encodings (names or aliases).
    :param exclude_encodings: If given, remove these encodings from the
        candidate set.
    :param no_match_encoding: Encoding to return when no candidate survives
        the pipeline.  Defaults to ``"cp1252"``.
    :param empty_input_encoding: Encoding to return for empty input.  Defaults
        to ``"utf-8"``.
    :returns: A list of dictionaries, sorted by descending confidence.
    r   r   r   r   r)   c                 S  s   g | ]}|  qS r4   )r,   ).0rr4   r4   r5   
<listcomp>   s    zdetect_all.<locals>.<listcomp>c                 S  s   g | ]
}|d  t kr|qS )
confidence)r   )r8   dr4   r4   r5   r:      s    c                 S  s   | d S )Nr;   r4   )r<   r4   r4   r5   <lambda>   s    zdetect_all.<locals>.<lambda>T)keyreverse)r	   r   r   r   r   r*   r+   r   r   r   sorted)r   r6   r    r"   r#   r%   r   r   r   r   r   r   r-   r.   r/   r0   r1   r2   dictsfilteredr<   r4   r4   r5   r   d   s:   -




	r   )r   r   r    r!   r"   r   r#   r$   r%   r$   r   r!   r   r!   r   r&   r   r&   r   r'   r   r'   r(   r   )r   r   r6   r!   r    r!   r"   r   r#   r$   r%   r$   r   r!   r   r!   r   r&   r   r&   r   r'   r   r'   r(   r7   )"__doc__
__future__r   collections.abcr   chardet._utilsr   r   r   r   r   r	   chardet._versionr
   chardet.detectorr   chardet.enumsr   r   chardet.equivalencesr   r   chardet.pipeliner   r   chardet.pipeline.orchestratorr   chardet.registryr   r   __all__ALLr   r   r4   r4   r4   r5   <module>   sJ     A