§
    |Ø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!dS )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dS )*Ú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_encodingÚlang_filterr   Úshould_rename_legacyÚboolÚencoding_erar   Ú	max_bytesÚintr   r   r   úIterable[str] | Noner   r   Ústrr    ÚreturnÚNonec               óÚ  — |t           j        k    rt          j        dt          d¬¦  «         t          ||¦  «        }|| _        || _        t          |¦  «         || _	        || _
        t          |d¦  «        | _        t          |d¦  «        | _        t          |	d¦  «        | _        t          |
d¦  «        | _        t#          ¦   «         | _        d| _        d| _        d| _        d	| _        d	S )
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)Úselfr!   r"   r$   r%   r   r   r   r   r   r    s              ú…/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/chardet/detector.pyÚ__init__zUniversalDetector.__init__3   s  € ðR �.Ô,Ò,Ð,ÝŒMð&å"Øð	ñ ô ð õ 3Ø  /ñ
ô 
ˆð !0ˆÔØ)ˆÔÝ˜IÑ&Ô&Ð&Ø)ˆÔØ#ˆŒÝ"5ØÐ2ñ#
ô #
ˆÔõ #6ØÐ2ñ#
ô #
ˆÔõ #5ØÐ2ñ#
ô #
ˆÔõ &8Ø Ð"8ñ&
ô &
ˆÔ"õ !‘{”{ˆŒØ %ˆÔØˆŒ
ØˆŒØ/3ˆŒˆˆó    Úbyte_strúbytes | bytearrayc                ó~  — | j         rd}t          |¦  «        ‚| j        r|rd| _        dS | j        t          | j        ¦  «        z
  }|dk    r"| j                             |d|…         ¦  «         t          |¦  «        t          |d¦  «        k    rd| _        t          | j        ¦  «        | j        k    r	d| _        dS dS )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   )	r>   Ú
ValueErrorr=   r<   r5   Úlenr;   ÚextendÚmax)r@   rD   ÚmsgÚ	remainings       rA   ÚfeedzUniversalDetector.feed}   sÍ   € ð Œ<ð 	"Ø?ˆCÝ˜S‘/”/Ð!ØŒ:ð 	ð ð -Ø(,�Ô%ØˆFØ”O¥c¨$¬,Ñ&7Ô&7Ñ7ˆ	Ø�qŠ=ˆ=ØŒL×Ò ¨¨)¨Ô 4Ñ5Ô5Ð5Ýˆx‰=Œ=�3˜y¨!Ñ,Ô,Ò,Ð,ð %)ˆDÔ!ÝˆtŒ|ÑÔ ¤Ò/Ð/ØˆDŒJˆJˆJð 0Ð/rC   r   c           
     óð   — | j         sid| _         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   )r>   Úbytesr;   r   r4   r5   r<   r6   r7   r8   r9   r?   r=   Úresult)r@   ÚdataÚresultss      rA   ÚclosezUniversalDetector.close�   s€   € ð Œ|ð 	ØˆDŒLÝ˜œÑ&Ô&ˆDÝ"ØØÔ"Øœ/Ø $Ô 5Ø"&Ô"9Ø"&Ô"9Ø"&Ô"9Ø%)Ô%?ð	ñ 	ô 	ˆGð # 1œ:ˆDŒLØˆDŒJØŒ{ÐrC   c                ód   — t          ¦   «         | _        d| _        d| _        d| _        d| _        dS )z2Reset the detector to its initial state for reuse.FN)r:   r;   r<   r=   r>   r?   ©r@   s    rA   ÚresetzUniversalDetector.reset¶   s.   € å ‘{”{ˆŒØ %ˆÔØˆŒ
ØˆŒØˆŒˆˆrC   c                ó   — | j         S )z9Whether detection is complete and no more data is needed.)r=   rV   s    rA   ÚdonezUniversalDetector.done¾   s   € ð ŒzÐrC   c                óH  — | 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.NrC   Úencoding)r   r   )r?   Úto_dictr2   r3   r   rP   r;   r   r6   r7   r   r   )r@   ÚdÚwindows      rA   rQ   zUniversalDetector.resultÃ   sÀ   € ð Œ<Ð#Ø”×$Ò$Ñ&Ô&ˆAð ˆFØÔ$ð -ØÔ"ð-Ø'(¨¤}Õ8NÐ'NÐ'Nå˜tœ|Ñ,Ô,�ØÔ$ð Ý(ØØØ&*Ô&=Ø&*Ô&=ð	ñ ô ð ð Ô!ð .Ý" 1 fÑ-Ô-Ð-ØˆHÝÔ#Ñ%Ô%Ð%rC   )r!   r   r"   r#   r$   r   r%   r&   r   r#   r   r#   r   r'   r   r'   r   r(   r    r(   r)   r*   )rD   rE   r)   r*   )r)   r   )r)   r*   )r)   r#   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚMINIMUM_THRESHOLDr   r   r   Ú__annotations__r   r.   r   r   rB   rM   rT   rW   ÚpropertyrY   rQ   © rC   rA   r   r      s&  € € € € € € ðð ð Ô0Ðð 8HÐ7GØñ8ô 8€Jð ð ð ñ ð '5Ô&8Ø%*Ø$/¤OØ*ðH4ð !&Ø!Ø26Ø26Ø!)Ø$+ðH4ð H4ð H4ð H4ð H4ð H4ðTð ð ð ð@ð ð ð ð2ð ð ð ð ðð ð ñ „Xðð ð&ð &ð &ñ „Xð&ð &ð &rC   r   )"rb   Ú
__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   rf   rC   rA   ú<module>rr      s}  ðØ 9Ð 9à "Ð "Ð "Ð "Ð "Ð "à €€€Ø $Ð $Ð $Ð $Ð $Ð $Ø "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð
 6Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5ðð ð ð ð ð ð ð ð ð ð ð ð JÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IØ 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø DÐ DÐ DÐ DÐ DÐ DÐ DÐ Dð~&ð ~&ð ~&ð ~&ð ~&ñ ~&ô ~&ð ~&ð ~&ð ~&rC   