%PDF- %PDF-
Direktori : /lib/python3/dist-packages/chardet/__pycache__/ |
Current File : //lib/python3/dist-packages/chardet/__pycache__/codingstatemachine.cpython-312.pyc |
� �d� � �8 � d dl Z ddlmZ ddlmZ G d� d� Zy)� N� )�CodingStateMachineDict)�MachineStatec �f � e Zd ZdZdeddfd�Zdd�Zdedefd�Zdefd �Z de fd �Zede fd�� Z y) �CodingStateMachinea� A state machine to verify a byte sequence for a particular encoding. For each byte the detector receives, it will feed that byte to every active state machine available, one byte at a time. The state machine changes its state based on its previous state and the byte it receives. There are 3 states in a state machine that are of interest to an auto-detector: START state: This is the state to start with, or a legal byte sequence (i.e. a valid code point) for character has been identified. ME state: This indicates that the state machine identified a byte sequence that is specific to the charset it is designed for and that there is no other possible encoding which can contain this byte sequence. This will to lead to an immediate positive answer for the detector. ERROR state: This indicates the state machine identified an illegal byte sequence for that encoding. This will lead to an immediate negative answer for this encoding. Detector will exclude this encoding from consideration from here on. �sm�returnNc �� � || _ d| _ d| _ t j | _ d| _ t j t � | _ | j � y )Nr T)�_model�_curr_byte_pos�_curr_char_lenr �START�_curr_state�active�logging� getLogger�__name__�logger�reset)�selfr s �</usr/lib/python3/dist-packages/chardet/codingstatemachine.py�__init__zCodingStateMachine.__init__9 sI � ����������'�-�-�������'�'��1���� � �� c �. � t j | _ y �N)r r r �r s r r zCodingStateMachine.resetB s � �'�-�-��r �cc �J � | j d | }| j t j k( rd| _ | j d | | _ | j | j d z |z }| j d | | _ | xj dz c_ | j S )N�class_tabler �char_len_table�class_factor�state_tabler )r r r r r r )r r � byte_class� curr_states r � next_statezCodingStateMachine.next_stateE s� � � �[�[��/��2� ����|�1�1�1�"#�D��"&�+�+�.>�"?� �"K�D���%�%����N�(C�C�j�P� ��;�;�}�5�j�A������q� �����r c � � | j S r )r r s r �get_current_charlenz&CodingStateMachine.get_current_charlenR s � ��"�"�"r c � � | j d S )N�name�r r s r �get_coding_state_machinez+CodingStateMachine.get_coding_state_machineU s � ��{�{�6�"�"r c � � | j d S )N�languager* r s r r- zCodingStateMachine.languageX s � ��{�{�:�&�&r )r N)r � __module__�__qualname__�__doc__r r r �intr% r'