V?vx d Z ddlZddlZddlZddlmZmZmZ ddlm Z ddl mZ ddlm Z mZmZ ddlmZ dd lmZ dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ G d d 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)ListOptionalUnion )CharSetGroupProber) CharSetProber) InputStateLanguageFilterProbingState)EscCharSetProber)Latin1Prober)MacRomanProber)MBCSGroupProber) ResultDict)SBCSGroupProber) UTF1632Proberc X e Zd ZdZdZ ej d Z ej d Z ej d Z dddd d ddd dZ ddddddddZej dfdededdfdZedefd Zedefd Zedee fd Zd!dZdeeef ddfdZdefd 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) iso-8859-1z iso-8859-2z iso-8859-5z iso-8859-6z iso-8859-7z iso-8859-8 iso-8859-9ziso-8859-13zISO-8859-11GB18030CP949UTF-16)asciir ztis-620r gb2312zeuc-krzutf-16leFlang_filtershould_rename_legacyreturnNc d | _ d | _ g | _ d dd d| _ d| _ d| _ t j | _ d| _ || _ t j t | _ d| _ || _ | d S )N encoding confidencelanguageF )_esc_charset_prober_utf1632_prober_charset_probersresultdone _got_datar PURE_ASCII_input_state _last_charr logging getLogger__name__logger_has_win_bytesr reset)selfr r s k/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/chardet/universaldetector.py__init__zUniversalDetector.__init__d s @D 8<57# # &1&'11#$8! r% c | j S N)r- r5 s r6 input_statezUniversalDetector.input_state{ s r% c | j S r9 )r3 r: s r6 has_win_byteszUniversalDetector.has_win_bytes s ""r% c | j S r9 )r( r: s r6 charset_probersz!UniversalDetector.charset_probers s $$r% c 2 dddd| _ d| _ d| _ d| _ t j | _ d| _ | j r| j | 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. Nr r! Fr% )r) r* r+ r3 r r, r- r. r&