(value)
return value
Try to convert the contents of value to ascii string.

    When the `value` cannot be converted to an ascii string, it returns the
    value.

    Args:
        value (dict, list, str): The value to convert.
    Returns:
        The `value` object with its contents translated if it was possible.

    Note:
        We get the ``uids`` info as binary when using the methods of
        :py:class:`isbg.imaputils.IsbgImap4`.

    Examples:
        >>> get_ascii_or_value('isbg - IMAP Spam Begone')
        'isbg - IMAP Spam Begone'
        >>> d = {'isbg': (u'IMAP', [b'Spam', r'Begone'])}
        >>> get_ascii_or_value(d)
        {'isbg': ('IMAP', ['Spam', 'Begone'])}
Try to convert the contents of value to ascii string.
Try to convert the contents of value to ascii string .
def get_ascii_or_value(value):
    """Try to convert the contents of value to ascii string.

    When the `value` cannot be converted to an ascii string, it returns the
    value.

    Args:
        value (dict, list, str): The value to convert.
    Returns:
        The `value` object with its contents translated if it was possible.

    Note:
        We get the ``uids`` info as binary when using the methods of
        :py:class:`isbg.imaputils.IsbgImap4`.

    Examples:
        >>> get_ascii_or_value('isbg - IMAP Spam Begone')
        'isbg - IMAP Spam Begone'
        >>> d = {'isbg': (u'IMAP', [b'Spam', r'Begone'])}
        >>> get_ascii_or_value(d)
        {'isbg': ('IMAP', ['Spam', 'Begone'])}

    """
    def _get_ascii_or_value(val):
        """Try to convert to string.

        Args:
            val(str, byte): the value to convert.
        Returns:
            The value converted (or nor).

        """
        try:
            return val.decode('ascii')
        except UnicodeDecodeError:
            return val

    if isinstance(value, bytes):
        return _get_ascii_or_value(value)

    if isinstance(value, (list, tuple)):
        lis = []
        for v in value:
            lis.append(get_ascii_or_value(v))
        if isinstance(value, tuple):
            lis = tuple(lis)
        return lis

    if isinstance(value, dict):
        dic = {}
        for k, v in value.items():
            dic[get_ascii_or_value(k)] = get_ascii_or_value(v)
        return dic

    return value
def get_ascii_or_value ( value ) : def _get_ascii_or_value ( val ) : """Try to convert to string.

        Args:
            val(str, byte): the value to convert.
        Returns:
            The value converted (or nor).

        """ try : return val . decode ( 'ascii' ) except UnicodeDecodeError : return val if isinstance ( value , bytes ) : return _get_ascii_or_value ( value ) if isinstance ( value , ( list , tuple ) ) : lis = [ ] for v in value : lis . append ( get_ascii_or_value ( v ) ) if isinstance ( value , tuple ) : lis = tuple ( lis ) return lis if isinstance ( value , dict ) : dic = { } for k , v in value . items ( ) : dic [ get_ascii_or_value ( k ) ] = get_ascii_or_value ( v ) return dic return value