Ë
    ^ãj5"  ã                  óÌ   — d Z ddlmZ ddl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mZ dd	lmZmZ dd
lmZmZmZmZ ddlmZmZmZ ddlmZ ddlmZm Z   G d„ d«      Z!y)u3   UniversalDetector â€” streaming encoding detection.é    )ÚannotationsN)ÚIterable)ÚMappingProxyType)ÚClassVar)Ú_utils)ÚDEFAULT_MAX_BYTESÚ_resolve_prefer_supersetÚ_validate_max_bytes)ÚEncodingEraÚLanguageFilter)ÚNARROWER_DISPLAY_NAMESÚPREFERRED_SUPERSETÚapply_compat_namesÚapply_preferred_superset)Ú_NONE_RESULTÚDetectionDictÚDetectionResult)Úrun_pipeline)Ú_validate_encodingÚnormalize_encodingsc                  óô   — e Zd ZU dZej
                  Z ee«      Zde	d<   e
j                  dej                  efddddddd	œ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
„Zdd„Zdd„Zdd„Zedd„«       Zedd„«       Zy)ÚUniversalDetectora  Streaming character encoding detector.

    Implements a feed/close pattern for incremental detection of character
    encoding from byte streams.  Compatible with the chardet 6.x API.

    All detection is performed by the same pipeline used by
    :func:`chardet.detect` and :func:`chardet.detect_all`, ensuring
    consistent results regardless of which API is used.

    .. note::

        This class is **not** thread-safe.  Each thread should create its own
        :class:`UniversalDetector` instance.
    z$ClassVar[MappingProxyType[str, str]]Ú
LEGACY_MAPFTNÚcp1252zutf-8)Úprefer_supersetÚcompat_namesÚinclude_encodingsÚexclude_encodingsÚno_match_encodingÚempty_input_encodingc               ó¦  — |t         j                  k7  rt        j                  dt        d¬«       t        ||«      }|| _        || _        t        |«       || _	        || _
        t        |d«      | _        t        |d«      | _        t        |	d«      | _        t        |
d«      | _        t#        «       | _        d| _        d| _        d| _        d	| _        y	)
a*  Initialize the detector.

        :param lang_filter: Deprecated -- accepted for backward compatibility
            but has no effect.  A warning is emitted when set to anything
            other than :attr:`LanguageFilter.ALL`.
        :param should_rename_legacy: Deprecated alias for *prefer_superset*.
        :param encoding_era: Restrict candidate encodings to the given era.
        :param max_bytes: Maximum number of bytes to buffer from
            :meth:`feed` calls before stopping accumulation.
        :param prefer_superset: If ``True``, remap subset encodings in the
            result to their decode-safe Windows/CP superset equivalents
            (e.g., ISO-8859-1 -> Windows-1252).  If ``False`` (default),
            skip the renaming --- not a promise of the smallest matching
            encoding.  The default will change to ``True`` in chardet 8.0.
            See :func:`chardet.detect` for details.
        :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"``.
        zMlang_filter is not implemented in this version of chardet and will be ignoredé   )Ú
stacklevelr   r   r   r    FN)r   ÚALLÚwarningsÚwarnÚDeprecationWarningr	   Ú_prefer_supersetÚ_compat_namesr
   Ú_encoding_eraÚ
_max_bytesr   Ú_include_encodingsÚ_exclude_encodingsr   Ú_no_match_encodingÚ_empty_input_encodingÚ	bytearrayÚ_bufferÚ_input_truncatedÚ_doneÚ_closedÚ_result)ÚselfÚlang_filterÚshould_rename_legacyÚencoding_eraÚ	max_bytesr   r   r   r   r   r    s              úR/var/www/html/metafoliadorv2/venv/lib/python3.12/site-packages/chardet/detector.pyÚ__init__zUniversalDetector.__init__3   sÞ   € ðR œ.×,Ñ,Ò,Ü�M‰Mð&ä"Øõ	ô 3Ø  /ó
ˆð !0ˆÔØ)ˆÔÜ˜IÔ&Ø)ˆÔØ#ˆŒÜ"5ØÐ2ó#
ˆÔô #6ØÐ2ó#
ˆÔô #5ØÐ2ó#
ˆÔô &8Ø Ð"8ó&
ˆÔ"ô !“{ˆŒØ %ˆÔØˆŒ
ØˆŒØ/3ˆ�ó    c                ó~  — | j                   rd}t        |«      ‚| j                  r
|rd| _        y| j                  t        | j                  «      z
  }|dkD  r| j                  j                  |d| «       t        |«      t        |d«      kD  rd| _        t        | j                  «      | j                  k\  rd| _        yy)a‘  Feed a chunk of bytes to the detector.

        Data is accumulated in an internal buffer.  Once *max_bytes* have
        been buffered, :attr:`done` is set to ``True`` and further data is
        ignored until :meth:`reset` is called.

        :param byte_str: The next chunk of bytes to examine.
        :raises ValueError: If called after :meth:`close` without a
            :meth:`reset`.
        z+feed() called after close() without reset()TNr   )	r4   Ú
ValueErrorr3   r2   r+   Úlenr1   ÚextendÚmax)r6   Úbyte_strÚmsgÚ	remainings       r;   ÚfeedzUniversalDetector.feed}   s¦   € ð �<Š<Ø?ˆCÜ˜S“/Ð!Ø�:Š:ñ Ø(,�Ô%ØØ—O‘O¤c¨$¯,©,Ó&7Ñ7ˆ	Ø�qŠ=Ø�L‰L×Ñ ¨¨)Ð 4Ô5Üˆx‹=œ3˜y¨!Ó,Ò,ð %)ˆDÔ!Üˆt�|‰|Ó §¡Ò/ØˆD�Jð 0r=   c           
     ó>  — | j                   s†d| _         t        | j                  «      }t        || j                  | j
                  | j                  | j                  | j                  | j                  | j                  ¬«      }|d   | _        d| _        | j                  S )zôFinalize detection and return the best result.

        Runs the full detection pipeline on the buffered data.

        :returns: A dictionary with keys ``"encoding"``, ``"confidence"``,
            ``"language"``, and ``"mime_type"``.
        T)r:   Úinput_truncatedr   r   r   r    r   )r4   Úbytesr1   r   r*   r+   r2   r,   r-   r.   r/   r5   r3   Úresult)r6   ÚdataÚresultss      r;   ÚclosezUniversalDetector.close�   sˆ   € ð �|Š|ØˆDŒLÜ˜Ÿ™Ó&ˆDÜ"ØØ×"Ñ"ØŸ/™/Ø $× 5Ñ 5Ø"&×"9Ñ"9Ø"&×"9Ñ"9Ø"&×"9Ñ"9Ø%)×%?Ñ%?ô	ˆGð # 1™:ˆDŒLØˆDŒJØ�{‰{Ðr=   c                óZ   — t        «       | _        d| _        d| _        d| _        d| _        y)z2Reset the detector to its initial state for reuse.FN)r0   r1   r2   r3   r4   r5   ©r6   s    r;   ÚresetzUniversalDetector.reset¶   s(   € ä “{ˆŒØ %ˆÔØˆŒ
ØˆŒØˆ�r=   c                ó   — | j                   S )z9Whether detection is complete and no more data is needed.)r3   rO   s    r;   ÚdonezUniversalDetector.done¾   s   € ð �z‰zÐr=   c                ó|  — | j                   ��| j                   j                  «       }d}| j                  s| j                  r |d   t        v rt        | j                  «      }| j                  r#t        ||| j                  | j                  ¬«       | j                  rt        ||«       |S t        j                  «       S )z"The current best detection result.r=   Úencoding)r   r   )r5   Úto_dictr(   r)   r   rI   r1   r   r,   r-   r   r   )r6   ÚdÚwindows      r;   rJ   zUniversalDetector.resultÃ   s¥   € ð �<‰<Ð#Ø—‘×$Ñ$Ó&ˆAð ˆFØ×$Ò$Ø×"Ò" q¨¡}Ô8NÑ'Nä˜tŸ|™|Ó,�Ø×$Ò$Ü(ØØØ&*×&=Ñ&=Ø&*×&=Ñ&=õ	ð ×!Ò!Ü" 1 fÔ-ØˆHÜ×#Ñ#Ó%Ð%r=   )r7   r   r8   Úboolr9   r   r:   Úintr   rX   r   rX   r   úIterable[str] | Noner   rZ   r   Ústrr    r[   ÚreturnÚNone)rC   zbytes | bytearrayr\   r]   )r\   r   )r\   r]   )r\   rX   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚMINIMUM_THRESHOLDr   r   r   Ú__annotations__r   r$   r   r   r<   rF   rM   rP   ÚpropertyrR   rJ   © r=   r;   r   r      s  … ñð ×0Ñ0Ðñ 8HØó8€JÐ4ó ð '5×&8Ñ&8Ø%*Ø$/§O¡OØ*ðH4ð !&Ø!Ø26Ø26Ø!)Ø$+ñH4à#ðH4ð #ðH4ð "ð	H4ð
 ðH4ð ðH4ð ðH4ð 0ðH4ð 0ðH4ð ðH4ð "ðH4ð 
óH4óTó@ó2ð òó ðð ò&ó ñ&r=   r   )"ra   Ú
__future__r   r%   Úcollections.abcr   Útypesr   Útypingr   Úchardetr   Úchardet._utilsr   r	   r
   Úchardet.enumsr   r   Úchardet.output_namesr   r   r   r   Úchardet.pipeliner   r   r   Úchardet.pipeline.orchestratorr   Úchardet.registryr   r   r   re   r=   r;   ú<module>rq      sN   ðÙ 9å "ã Ý $Ý "Ý å ÷ñ ÷
 6÷ó ÷ JÑ IÝ 6ß D÷~&ò ~&r=   