""" Fix the syntax error in download patches """ import os from pathlib import Path scripts_dir = Path("c:/numerai48models/scripts") all_scripts = list(scripts_dir.rglob("*.py")) fixed = 0 for script in all_scripts: try: with open(script, 'r', encoding='utf-8', errors='ignore') as f: content = f.read() # Fix the broken download syntax if 'napi.download_dataset( if not SKIP_API' in content: # Fix napi content = content.replace( 'napi.download_dataset( if not SKIP_API else print(" [SKIP_API] Skip download") or (', 'if not SKIP_API: napi.download_dataset(' ) # Fix sapi content = content.replace( 'sapi.download_dataset( if not SKIP_API else print(" [SKIP_API] Skip download") or (', 'if not SKIP_API: sapi.download_dataset(' ) # Fix capi content = content.replace( 'capi.download_dataset( if not SKIP_API else print(" [SKIP_API] Skip download") or (', 'if not SKIP_API: capi.download_dataset(' ) with open(script, 'w', encoding='utf-8', errors='ignore') as f: f.write(content) print(f"[OK] {script.relative_to(scripts_dir)}") fixed += 1 except Exception as e: print(f"[ERR] {script.name}: {e}") print(f"\nFixed {fixed} scripts!")