

def check_and_cythonize(root_dir):
    print(root_dir)
    hashes = load_hashes(HASH_FILE)
    for (cur_dir, dirs, files) in os.walk(root_dir):
        for filename in files:
            if filename.endswith('.pyx'):
                gen_file_ext = '.c'
                with open(os.path.join(cur_dir, filename), 'rb') as f:
                    data = f.read()
                    m = re.search(b'libcpp', data, (re.I | re.M))
                    if m:
                        gen_file_ext = '.cpp'
                cython_file = filename
                gen_file = filename.replace('.pyx', gen_file_ext)
                cythonize_if_unchanged(cur_dir, cython_file, gen_file, hashes)
                save_hashes(hashes, HASH_FILE)

dataset/ETHPy150Open jakevdp/cython_template/tools/cythonize.py check_and_cythonize/original