Ë
    Dü´j}  ã                  óÈ   — 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 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)Ú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              úN/root/workspace/ytshorts/venv/lib/python3.12/site-packages/chardet/detector.pyÚ__init__zUniversalDetector.__init__2   sÞ   € ðR œ.×,Ñ,Ò,Ü�M‰Mð&ä"Øõ	ô 3Ø  /ó
ˆð !0ˆÔØ)ˆÔÜ˜IÔ&Ø)ˆÔØ#ˆŒÜ"5ØÐ2ó#
ˆÔô #6ØÐ2ó#
ˆÔô #5ØÐ2ó#
ˆÔô &8Ø Ð"8ó&
ˆÔ"ô !“{ˆŒØ %ˆÔØˆŒ
ØˆŒØ/3ˆ�ó    c                ól  — | j                   rd}t        |«      ‚| j                  r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()Nr   T)	r3   Ú
ValueErrorr2   r*   Úlenr0   ÚextendÚmaxr1   )r5   Ú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"``,
            and ``"language"``.
        T)r9   Úinput_truncatedr   r   r   r   r   )r3   Úbytesr0   r   r)   r*   r1   r+   r,   r-   r.   r4   r2   Úresult)r5   Ú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)r/   r0   r1   r2   r3   r4   ©r5   s    r:   ÚresetzUniversalDetector.reset°   s(   € ä “{ˆŒØ %ˆÔØˆŒ
ØˆŒØˆ�r<   c                ó   — | j                   S )z9Whether detection is complete and no more data is needed.)r2   rN   s    r:   ÚdonezUniversalDetector.done¸   s   € ð �z‰zÐr<   c                óÖ   — | j                   �J| j                   j                  «       }| j                  rt        |«       | j                  rt        |«       |S t        j                  «       S )z"The current best detection result.)r4   Úto_dictr'   r   r(   r   r   )r5   Úds     r:   rI   zUniversalDetector.result½   sV   € ð �<‰<Ð#Ø—‘×$Ñ$Ó&ˆAØ×$Ò$Ü(¨Ô+Ø×!Ò!Ü" 1Ô%ØˆHÜ×#Ñ#Ó%Ð%r<   )r6   r   r7   Úboolr8   r   r9   Úintr   rU   r   rU   r   úIterable[str] | Noner   rW   r   Ústrr   rX   ÚreturnÚNone)rB   zbytes | bytearrayrY   rZ   )rY   r   )rY   rZ   )rY   rU   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚMINIMUM_THRESHOLDr   r   r   Ú__annotations__r   r#   r   r   r;   rE   rL   rO   ÚpropertyrQ   rI   © 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ó6ó2ð òó ðð ò	&ó ñ	&r<   r   )!r^   Ú
__future__r   r$   Úcollections.abcr   Útypesr   Útypingr   Úchardetr   Úchardet._utilsr   r	   r
   Úchardet.enumsr   r   Úchardet.output_namesr   r   r   Úchardet.pipeliner   r   r   Úchardet.pipeline.orchestratorr   Úchardet.registryr   r   r   rb   r<   r:   ú<module>rn      sN   ðÙ 9å "ã Ý $Ý "Ý å ÷ñ ÷
 6÷ñ ÷
 JÑ IÝ 6ß D÷l&ò l&r<   