a _b @sDddlmZddlmZddlmZmZgdZddZddZ d S) )UniversalDetector) InputState) __version__VERSION)rdetect detect_allrrcCsHt|ts0t|ts(tdt|nt|}t}|||S)z Detect the encoding of the given byte string. :param byte_str: The byte sequence to examine. :type byte_str: ``bytes`` or ``bytearray`` 3Expected object of type bytes or bytearray, got: {}) isinstance bytearraybytes TypeErrorformattyperfeedclose)byte_strdetectorr7/tmp/pip-target-4jja1joz/lib/python/chardet/__init__.pyrs   rcCst|ts0t|ts(tdt|nt|}t}||||j t j krg}|j D]X}| |jkr^|j}|j}|dr|jr|j||}||| |jdq^t|dkrt|dddS|jgS)z Detect all the possible encodings of the given byte string. :param byte_str: The byte sequence to examine. :type byte_str: ``bytes`` or ``bytearray`` rziso-8859)encoding confidencelanguagecSs |d S)Nrr)resultrrrQzdetect_all..)key)r r r r r rrrr _input_stater HIGH_BYTE_charset_probersget_confidenceMINIMUM_THRESHOLD charset_namelower startswith_has_win_bytes ISO_WIN_MAPgetappendrlensortedr)rrresultsproberr"lower_charset_namerrrr-s8         rN) universaldetectorrenumsrversionrr__all__rrrrrrs