⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.30
Server IP:
45.79.8.107
Server:
Linux localhost 5.15.0-140-generic #150-Ubuntu SMP Sat Apr 12 06:00:09 UTC 2025 x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.2-1ubuntu2.21
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib
/
python3
/
dist-packages
/
chardet
/
__pycache__
/
View File Name :
universaldetector.cpython-310.pyc
o n_0 @ s d Z ddlZddlZddlZddlmZ ddlmZmZm Z ddl mZ ddlm Z ddlmZ dd lmZ G d d deZdS )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 @ sn e Zd ZdZdZedZedZedZ dddd d ddd dZ ejfddZ dd Zdd Zdd 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 C sN d | _ g | _d | _d | _d | _d | _d | _|| _t t | _d | _| d S )N)_esc_charset_prober_charset_probersresultdone _got_data_input_state _last_charlang_filterloggingZ getLogger__name__logger_has_win_bytesreset)selfr r ;/usr/lib/python3/dist-packages/chardet/universaldetector.py__init__Q s zUniversalDetector.__init__c C sV dddd| _ d| _d| _d| _tj| _d| _| jr| j | j D ]}| q"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 confidencelanguageF )r r r r r PURE_ASCIIr r r r r )r proberr r r r ^ s zUniversalDetector.resetc C s6 | j rdS t|sdS t|tst|}| jso|tjr%dddd| _n;|tj tj fr6dddd| _n*|drCdddd| _n|d rPd ddd| _n|tjtjfr`dddd| _d| _| jd durod| _ dS | j tjkr| j|rtj| _ n| j tjkr| j| j| rtj| _ |dd | _| j tjkr| jst| j| _| j|tjkr| jj| j | jjd| _d| _ dS dS | j tjkr| jst | jg| _| jt!j"@ r| j#t$ | j#t% | jD ]}||tjkr |j| |jd| _d| _ nq| j&|rd| _'dS dS dS )a Takes a chunk of a document and feeds it through all of the relevant charset probers. After calling ``feed``, you can check the value of the ``done`` attribute to see if you need to continue feeding the ``UniversalDetector`` more data, or if it has made a prediction (in the ``result`` attribute). .. note:: You should always call ``close`` when you're done feeding in your document if ``done`` is not already ``True``. Nz UTF-8-SIG ? r zUTF-32s zX-ISO-10646-UCS-4-3412s zX-ISO-10646-UCS-4-2143zUTF-16Tr )(r len isinstance bytearrayr startswithcodecsBOM_UTF8r BOM_UTF32_LEBOM_UTF32_BEBOM_LEBOM_BEr r r# HIGH_BYTE_DETECTORsearch HIGH_BYTEESC_DETECTORr Z ESC_ASCIIr r r feedr ZFOUND_ITcharset_nameget_confidencer! r r r ZNON_CJKappendr r WIN_BYTE_DETECTORr )r Zbyte_strr$ r r r r6 o s zUniversalDetector.feedc C sf | j r| jS d| _ | js| jd nY| jtjkr!dddd| _nK| jtjkrld}d}d}| j D ]}|s5q0| }||krA|}|}q0|rl|| jkrl|j}|j }| }|d rd| jrd| j||}|||jd| _| j tjkr| jd du r| jd | j D ]+}|sqt|tr|jD ]}| jd|j|j| qq| jd|j|j| q| jS ) z Stop analyzing the current document and come up with a final prediction. :returns: The ``result`` attribute, a ``dict`` with the keys `encoding`, `confidence`, and `language`. Tzno data received!asciir% r&