ok
Direktori : /lib/python3.6/site-packages/chardet/__pycache__/ |
Current File : //lib/python3.6/site-packages/chardet/__pycache__/escprober.cpython-36.pyc |
3 ��Xn � @ sX d dl mZ d dlmZ d dlmZmZmZ d dlm Z m Z mZmZ G dd� de�Z dS )� )� CharSetProber)�CodingStateMachine)�LanguageFilter�ProbingState�MachineState)�HZ_SM_MODEL�ISO2022CN_SM_MODEL�ISO2022JP_SM_MODEL�ISO2022KR_SM_MODELc sV e Zd ZdZd� fdd� Z� fdd�Zedd� �Zed d � �Zdd� Z d d� Z � ZS )�EscCharSetProberz� This CharSetProber uses a "code scheme" approach for detecting encodings, whereby easily recognizable escape or shift sequences are relied on to identify these encodings. Nc s� t t| �j|d� g | _| jtj@ rD| jjtt �� | jjtt �� | jtj@ r`| jjtt�� | jtj @ r|| jjtt�� d | _d | _d | _d | _| j� d S )N)�lang_filter)�superr �__init__� coding_smr r ZCHINESE_SIMPLIFIED�appendr r r ZJAPANESEr ZKOREANr �active_sm_count�_detected_charset�_detected_language�_state�reset)�selfr )� __class__� �/usr/lib/python3.6/escprober.pyr * s zEscCharSetProber.__init__c sN t t| �j� x"| jD ]}|s qd|_|j� qW t| j�| _d | _d | _d S )NT) r r r r �active�lenr r r )r r )r r r r : s zEscCharSetProber.resetc C s | j S )N)r )r r r r �charset_nameE s zEscCharSetProber.charset_namec C s | j S )N)r )r r r r �languageI s zEscCharSetProber.languagec C s | j r dS dS d S )Ng�G�z��?g )r )r r r r �get_confidenceM s zEscCharSetProber.get_confidencec C s� x�|D ]�}x�| j D ]�}| s|j r&q|j|�}|tjkrhd|_| jd8 _| jdkr�tj| _| j S q|tj krtj| _|j� | _ |j| _| j S qW qW | j S )NFr � )r r Z next_stater ZERRORr r ZNOT_MEr �stateZITS_MEZFOUND_ITZget_coding_state_machiner r r )r Zbyte_str�cr Zcoding_stater r r �feedS s"