<commit_before>from girder.api.rest import RestException


def whitelist_cjson(cjson):
    # Find the cjson version key
    version_key = 'chemicalJson'
    if version_key not in cjson:
        if 'chemical json' in cjson:
            version_key = 'chemical json'
        else:
            raise RestException('No "chemicalJson" key found', 400)

    # Whitelist parts of the CJSON that we store at the top level.
    cjsonmol = {}
    cjsonmol['atoms'] = cjson['atoms']
    cjsonmol['bonds'] = cjson['bonds']
    cjsonmol['chemicalJson'] = cjson[version_key]

    return cjsonmol<commit_msg>Avoid key error for bonds in whitelist cjson<commit_after>from girder.api.rest import RestException


def whitelist_cjson(cjson):
    # Find the cjson version key
    version_key = 'chemicalJson'
    if version_key not in cjson:
        if 'chemical json' in cjson:
            version_key = 'chemical json'
        else:
            raise RestException('No "chemicalJson" key found', 400)

    # Whitelist parts of the CJSON that we store at the top level.
    cjsonmol = {}
    cjsonmol['atoms'] = cjson['atoms']
    cjsonmol['chemicalJson'] = cjson[version_key]

    if 'bonds' in cjson:
        # The bonds are important, but just in case they are missing...
        cjsonmol['bonds'] = cjson['bonds']

    return cjsonmol
{'fraction_non_alphanumeric': 0.09249431387414708, 'fraction_numerical': 0.004548900682335102, 'mean_word_length': 2.9520958083832336, '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': '6885254', 'n_tokens_mistral': 438, 'n_tokens_neox': 399, 'n_words': 129}