3 ¥íXÎ ã@sHddlmZddlmZmZddlmZddlmZGdd„deƒZ dS)é)Ú CharSetProber)Ú ProbingStateÚ MachineState)ÚCodingStateMachine)Ú UTF8_SM_MODELcsTeZdZdZ‡fdd„Z‡fdd„Zedd„ƒZedd „ƒZd d „Z d d „Z ‡Z S)Ú UTF8Probergà?cs*tt|ƒjƒttƒ|_d|_|jƒdS)N)ÚsuperrÚ__init__rrÚ coding_smÚ _num_mb_charsÚreset)Úself)Ú __class__©ú /usr/lib/python3.6/utf8prober.pyr &s zUTF8Prober.__init__cs"tt|ƒjƒ|jjƒd|_dS)Né)rrr r r )r )rrrr ,s zUTF8Prober.resetcCsdS)Nzutf-8r)r rrrÚ charset_name1szUTF8Prober.charset_namecCsdS)NÚr)r rrrÚlanguage5szUTF8Prober.languagecCs”xj|D]b}|jj|ƒ}|tjkr,tj|_Pq|tjkrBtj|_Pq|tj kr|jj ƒdkr|j d7_ qW|j tj krŽ|jƒ|jkrŽtj|_|j S)Nér)r Z next_staterZERRORrZNOT_MEZ_stateZITS_MEZFOUND_ITZSTARTZget_current_charlenr ÚstateZ DETECTINGÚget_confidenceZSHORTCUT_THRESHOLD)r Zbyte_strÚcZ coding_staterrrÚfeed9s      zUTF8Prober.feedcCs.d}|jdkr&||j|j9}d|S|SdS)Ng®Gáz®ï?égð?)r Ú ONE_CHAR_PROB)r ZunlikerrrrLs  zUTF8Prober.get_confidence) Ú__name__Ú __module__Ú __qualname__rr r ÚpropertyrrrrÚ __classcell__rr)rrr#s    rN) Z charsetproberrZenumsrrZcodingstatemachinerZmbcssmrrrrrrÚs