| 57 | return f"{function_name}_{variation}.py" |
| 58 | |
| 59 | def delete_old_scripts(sources_dirname, func_name): |
| 60 | dir_path = os.path.join(sources_dirname, func_name) |
| 61 | if os.path.exists(dir_path) and os.path.isdir(dir_path): |
| 62 | py_files = glob.glob(os.path.join(dir_path, "*.py")) |
| 63 | |
| 64 | # Iterate through the list of .py files and delete them |
| 65 | for py_file in py_files: |
| 66 | try: |
| 67 | os.remove(py_file) |
| 68 | print(f"Deleted {py_file}") |
| 69 | except OSError as e: |
| 70 | print(f"Error deleting {py_file}: {e}") |
| 71 | |
| 72 | def write_script_to_disk(code, sources_dirname, func_name, is_test=False, variation=0): |
| 73 | # Create the directory if it doesn't exist |