<commit_before>from collections import OrderedDict
from pprint import pprint


def equal_dicts(d1, d2):
    ''' Devolve True se dicionários são iguais.
    Só funciona se todos os valores forem serializáveis.
    '''
    return len(d1.items() ^ d2.items()) == 0


def update_dict(original, adding):
    result = original.copy()
    for key in adding.keys():
        if adding[key] is None:
            continue
        if isinstance(adding[key], dict):
            if key not in result or not isinstance(result[key], dict):
                result[key] = adding[key].copy()
            else:
                result[key] = update_dict(result[key], adding[key])
        else:
            result[key] = adding[key]
    return result


def dict_firsts(adict, firsts):
    eh_ordered = isinstance(adict, OrderedDict)
    if not eh_ordered:
        adict = OrderedDict(adict)
    keys = list(adict.keys())
    for key in keys:
        if key not in firsts:
            adict.move_to_end(key)
    if eh_ordered:
        return adict
    else:
        return dict(adict)<commit_msg>criada função dict_get_none<commit_after>from collections import OrderedDict
from pprint import pprint


def equal_dicts(d1, d2):
    ''' Devolve True se dicionários são iguais.
    Só funciona se todos os valores forem serializáveis.
    '''
    return len(d1.items() ^ d2.items()) == 0


def update_dict(original, adding):
    result = original.copy()
    for key in adding.keys():
        if adding[key] is None:
            continue
        if isinstance(adding[key], dict):
            if key not in result or not isinstance(result[key], dict):
                result[key] = adding[key].copy()
            else:
                result[key] = update_dict(result[key], adding[key])
        else:
            result[key] = adding[key]
    return result


def dict_firsts(adict, firsts):
    eh_ordered = isinstance(adict, OrderedDict)
    if not eh_ordered:
        adict = OrderedDict(adict)
    keys = list(adict.keys())
    for key in keys:
        if key not in firsts:
            adict.move_to_end(key)
    if eh_ordered:
        return adict
    else:
        return dict(adict)


def dict_get_none(dic, key):
    try:
        value = dic[key]
    except KeyError:
        value = dic.get(None)
    return value
{'fraction_non_alphanumeric': 0.09725250763192324, 'fraction_numerical': 0.00436109899694723, 'mean_word_length': 2.3246376811594205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1179452', 'n_tokens_mistral': 730, 'n_tokens_neox': 708, 'n_words': 205}