tools/utils.py
def dict_to_ascii(dictionary):
    """ Utility function: traverse a dictionary and change all the strings in
    the dictionary to ASCII from Unicode. Useful when reading ASCII JSON data,
    because the JSON decoder always returns Unicode string. Based on
    http://stackoverflow.com/a/13105359

    Positional arguments:
    dictionary - The dict that contains some Unicode that should be ASCII
    """
    if isinstance(dictionary, dict):
        return OrderedDict([(dict_to_ascii(key), dict_to_ascii(value))
                            for key, value in dictionary.iteritems()])
    elif isinstance(dictionary, list):
        return [dict_to_ascii(element) for element in dictionary]
    elif isinstance(dictionary, unicode):
        return dictionary.encode('ascii')
    else:
        return dictionary
 Utility function: traverse a dictionary and change all the strings in
    the dictionary to ASCII from Unicode. Useful when reading ASCII JSON data,
    because the JSON decoder always returns Unicode string. Based on
    http://stackoverflow.com/a/13105359

    Positional arguments:
    dictionary - The dict that contains some Unicode that should be ASCII
    
Utility function: traverse a dictionary and change all the strings in
the dictionary to ASCII from Unicode. Useful when reading ASCII JSON data,
because the JSON decoder always returns Unicode string.

Positional arguments:
dictionary - The dict that contains some Unicode that should be ASCII
Utility function : traverse a dictionary and change all the strings in the dictionary to ASCII from Unicode . Useful when reading ASCII JSON data because the JSON decoder always returns Unicode string . Positional arguments : dictionary - The dict that contains some Unicode that should be ASCII
def dict_to_ascii(dictionary):
    if isinstance(dictionary, dict):
        return OrderedDict([(dict_to_ascii(key), dict_to_ascii(value))
                            for key, value in dictionary.iteritems()])
    elif isinstance(dictionary, list):
        return [dict_to_ascii(element) for element in dictionary]
    elif isinstance(dictionary, unicode):
        return dictionary.encode('ascii')
    else:
        return dictionary
def dict_to_ascii ( dictionary ) : if isinstance ( dictionary , dict ) : return OrderedDict ( [ ( dict_to_ascii ( key ) , dict_to_ascii ( value ) ) for key , value in dictionary . iteritems ( ) ] ) elif isinstance ( dictionary , list ) : return [ dict_to_ascii ( element ) for element in dictionary ] elif isinstance ( dictionary , unicode ) : return dictionary . encode ( 'ascii' ) else : return dictionary
Utility function: traverse a dictionary and change all the strings in
the dictionary to ASCII from Unicode.
Utility function : traverse a dictionary and change all the strings in the dictionary to ASCII from Unicode .
""" Utility function: traverse a dictionary and change all the strings in
    the dictionary to ASCII from Unicode. Useful when reading ASCII JSON data,
    because the JSON decoder always returns Unicode string. Based on
    http://stackoverflow.com/a/13105359

    Positional arguments:
    dictionary - The dict that contains some Unicode that should be ASCII
    """
dictionary