def symbols_json_update(symbols_file, callback):
    other_file = open(symbols_file + '.new', 'w')
    other_file.write('{\n')
    for line in open(symbols_file, 'r').xreadlines():
        if len(line) < 3:
            continue
        [(lib, symbols)] = re.findall('^"(.*?)": (.*?),?$', line)
        symbols = json.loads(symbols)
        replacement = callback(lib, symbols)
        if replacement is None:
            other_file.write(line)
        else:
            other_file.write('"%s": %s,\n' % (lib, json.dumps(replacement)))
    if replacement is not None:
        other_file.seek(-2, 1)
        other_file.write('\n')
    other_file.write('}\n')
    os.rename(symbols_file + '.new', symbols_file)
dataset/ETHPy150Open molnarg/libc-binary-collection/tools/extract_main_call_sites.py/symbols_json_update/original