� ��^i�0���dZddlZddlZddlZddlmZddlmZmZm Z ddl m Z ddl m Z ddlmZdd lmZGd �d e��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)� InputState�LanguageFilter� ProbingState)�EscCharSetProber)� Latin1Prober)�MBCSGroupProber)�SBCSGroupProberc ��eZdZdZdZejd��Zejd��Zejd��Z dddd d d d d d�Z e j fd�Z 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[�-�]z Windows-1252z Windows-1250z Windows-1251z Windows-1256z Windows-1253z Windows-1255z Windows-1254z Windows-1257)z iso-8859-1z iso-8859-2z iso-8859-5z iso-8859-6z iso-8859-7z iso-8859-8z iso-8859-9z iso-8859-13c���d|_g|_d|_d|_d|_d|_d|_||_tj t��|_ d|_ |� ��dS)N)�_esc_charset_prober�_charset_probers�result�done� _got_data� _input_state� _last_char� lang_filter�logging� getLogger�__name__�logger�_has_win_bytes�reset)�selfrs ��/builddir/build/BUILDROOT/alt-python311-pip-21.3.1-4.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/chardet/universaldetector.py�__init__zUniversalDetector.__init__Qsi��#'�� � "����� ��� ���� ������&����'��1�1�� �"��� � � � � � � � �c���dddd�|_d|_d|_d|_tj|_d|_|jr|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� confidence�languageFr ) rrrrr� PURE_ASCIIrrrrr)r�probers rrzUniversalDetector.reset^s��� $(�s��M�M�� ��� ����#���&�1������ � #� -� � $� *� *� ,� ,� ,��+� � �F� �L�L�N�N�N�N� � r c��|jrdSt|��sdSt|t��st|��}|js�|�t j��r dddd�|_n�|�t j t j f��r dddd�|_nx|�d��r dddd�|_nW|�d ��r d ddd�|_n6|�t j t j f��r d ddd�|_d |_|jd � d |_dS|j tjkrt|j�|��rtj|_ nH|j tjkr3|j�|j|z��rtj|_ |dd�|_|j tjkr�|jst/|j��|_|j�|��t4jkr?|jj|j���|jjd�|_d |_dSdS|j tjk�r|jsztA|j��g|_|jtBj"zr&|j�#tI����|j�#tK����|jD]U}|�|��t4jkr0|j|���|jd�|_d |_n�V|j&�|��r d |_'dSdSdS)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� startswith�codecs�BOM_UTF8r� BOM_UTF32_LE� BOM_UTF32_BE�BOM_LE�BOM_BErrr'�HIGH_BYTE_DETECTOR�search� HIGH_BYTE� ESC_DETECTORr� ESC_ASCIIrrr�feedr�FOUND_IT� charset_name�get_confidencer&rr r�NON_CJK�appendr r �WIN_BYTE_DETECTORr)r�byte_strr(s rr<zUniversalDetector.feedos��� �9� � �F��8�}�}� � �F��(�I�.�.� +� ��*�*�H��~�" ��"�"�6�?�3�3� /�+6�-0�+-�/�/�� � ��$�$�f�&9�&,�&9�&;�<�<� /�,4�-0�+-�/�/�� � ��$�$�%8�9�9� /�+C�-0�+-�/�/�� � ��$�$�%8�9�9� /�+C�-0�+-�/�/�� � ��$�$�f�m�V�]�%C�D�D� /�,4�-0�+-�/�/�� �"�D�N��{�:�&�2� �� ��� � � � 5� 5� 5��&�-�-�h�7�7� 9�$.�$8��!�!��"�j�&;�;�;��%�,�,�T�_�x�-G�H�H�<�$.�$8��!�"�2�3�3�-��� � � � 4� 4� 4��+� N�+;�D��lowerr0r� ISO_WIN_MAP�getr&�getEffectiveLevelr�DEBUGr.r�probers) r�prober_confidence�max_prober_confidence� max_proberr(r>�lower_charset_namer%� group_probers r�closezUniversalDetector.close�s��� �9� ��;� ��� ��~�! @� �K� � �1� 2� 2� 2� 2�� �*�"7� 7� 7�'.�),�')�+�+�D�K�K� � �*�"6� 6� 6� $� �$'� !��J��/� (� (�����$*�$9�$9�$;�$;�!�$�'<�<�<�,=�)�!'�J��� @�4�t�7M�M�M�)�6� �%/�%<�%B�%B�%D�%D�"�'�6�6�8�8� �&�0�0��<�<�J��*�J�'+�'7�';�';��@�@�� � �;� (� (� *� *�g�m� ;� ;��{�:�&�.�� �!�!�"D�E�E�E�$(�$9� I� I�L�'�!� �!�,�0B�C�C� I�&2�&:�G�G�F� �K�-�-�.E�.4�.A�.4�o�.4�.C�.C�.E�.E�G�G�G�G�G� � �)�)�*A�*6�*C�*6�*?�*6�*E�*E�*G�*G�I�I�I�I��{�r N)r� __module__� __qualname__�__doc__rG�re�compiler7r:rBrIr�ALLrrr<rS�r rr r 3s��������� ��#���N�3�3���2�:�l�+�+�L�"�� �>�2�2��!/�!/�!/�!/�!/�!/�!/�"0�2�2�K�$2�#5� � � � ����"k+�k+�k+�ZB�B�B�B�Br r )rVr1rrW�charsetgroupproberr�enumsrrr� escproberr� latin1proberr �mbcsgroupproberr �sbcsgroupproberr �objectr rZr r�rbs���8��� � � ����� � � � �2�2�2�2�2�2�;�;�;�;�;�;�;�;�;�;�'�'�'�'�'�'�&�&�&�&�&�&�,�,�,�,�,�,�,�,�,�,�,�,�k�k�k�k�k��k�k�k�k�kr