(byte_sring)
return ret
Try to detect a encoding.

    It uses the ``cchardet`` and ``chardet`` modules to detect the encoding.
    If none of them are installed, it returns None.

    Args:
        byte_string (str | bytes): the byte string to detect.

    Return:
        dict: with at least the 'encoding' informed as returned by
            :py:func:`cchardet.detect` and :py:func:`chardet.detect`.
Try to detect a encoding.
Try to detect a encoding .
def detect_enc(byte_sring):
    """Try to detect a encoding.

    It uses the ``cchardet`` and ``chardet`` modules to detect the encoding.
    If none of them are installed, it returns None.

    Args:
        byte_string (str | bytes): the byte string to detect.

    Return:
        dict: with at least the 'encoding' informed as returned by
            :py:func:`cchardet.detect` and :py:func:`chardet.detect`.

    """
    try:
        ret = cchardet.detect(byte_sring)
    except NameError:
        ret = None

    if not ret or 'encoding' not in ret or not ret['encoding'] or \
            ret['encoding'] == '':
        try:
            ret = chardet.detect(byte_sring)
        except NameError:
            pass

    if not ret or not ret['encoding']:
        return {'encoding': None}

    return ret
def detect_enc ( byte_sring ) : try : ret = cchardet . detect ( byte_sring ) except NameError : ret = None if not ret or 'encoding' not in ret or not ret [ 'encoding' ] or ret [ 'encoding' ] == '' : try : ret = chardet . detect ( byte_sring ) except NameError : pass if not ret or not ret [ 'encoding' ] : return { 'encoding' : None } return ret