.b٢ d Z ddlZddlZddlZddlmZ ddlmZmZm Z ddl mZ ddlm Z ddlmZ dd lmZ G d de ZdS )a Module containing the UniversalDetector detector class, which is the primary class a user of ``chardet`` should use. :author: Mark Pilgrim (initial port to Python) :author: Shy Shalom (original C code) :author: Dan Blanchard (major refactoring for 3.0) :author: Ian Cordasco N )CharSetGroupProber) InputStateLanguageFilterProbingState)EscCharSetProber)Latin1Prober)MBCSGroupProber)SBCSGroupProberc e Zd ZdZdZ ej d Z ej d Z ej d Z dddd d ddd dZ ej fdZ d Zd Zd ZdS )UniversalDetectoraq The ``UniversalDetector`` class underlies the ``chardet.detect`` function and coordinates all of the different charset probers. To get a ``dict`` containing an encoding and its confidence, you can simply run: .. code:: u = UniversalDetector() u.feed(some_bytes) u.close() detected = u.result g?s [-]s (|~{)s [-]zWindows-1252zWindows-1250zWindows-1251zWindows-1256zWindows-1253zWindows-1255zWindows-1254zWindows-1257)z iso-8859-1z iso-8859-2z iso-8859-5z iso-8859-6z iso-8859-7z iso-8859-8z iso-8859-9ziso-8859-13c d | _ g | _ d | _ d | _ d | _ d | _ d | _ || _ t j t | _ d | _ | d S )N)_esc_charset_prober_charset_probersresultdone _got_data_input_state _last_charlang_filterlogging getLogger__name__logger_has_win_bytesreset)selfr s /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el9.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/chardet/universaldetector.py__init__zUniversalDetector.__init__Q si #' " &'11" c dddd| _ d| _ d| _ d| _ t j | _ d| _ | j r| j | j D ]}| dS )z Reset the UniversalDetector and all of its probers back to their initial states. This is called by ``__init__``, so you only need to call this directly in between analyses of different documents. N encoding confidencelanguageFr )r r r r r PURE_ASCIIr r r r r )r probers r r zUniversalDetector.reset^ s $(sMM #&1# -$**,,,+ FLLNNNN r c | j rdS t | sdS t |t st | }| j s| t j rdddd| _ n| t j t j f rdddd| _ nx| d rdddd| _ nW| d rd ddd| _ n6| t j t j f rdddd| _ d| _ | j d d| _ dS | j t j k rt| j | rt j | _ nH| j t j k r3| j | j |z rt j | _ |dd | _ | j t j k r| j st/ | j | _ | j | t4 j k r?| j j | j | j j d| _ d| _ dS dS | j t j k r| j sztA | j g| _ | j tB j" z r&| j # tI | j # tK | j D ]U}| | t4 j k r0|j | |j d| _ d| _ nV| j&