def byte_to_str(text, do_convert=True):
    """
    make sure `text` is string if `do_convert`

    :raise AttributeError: Text is not processable
    """
    if not do_convert:
        return text
    elif isinstance(text, str):
        return text
    elif isinstance(text, bytes):
        return text.decode()
    else:
        raise AttributeError(
            'Unable to convert {} to string.Text should be string or bytes'
            .format(type(text)))
