import shutil from pathlib import Path def copy_static(destination: str) -> None: source_path = Path("static") destination_path = Path(destination) if not source_path.exists(): raise FileNotFoundError(f"Source directory '{source_path}' does not exist.") if destination_path.exists(): print(f"Cleaning contents of '{destination_path}'...") for item in destination_path.iterdir(): if item.is_dir(): shutil.rmtree(item) else: item.unlink() else: destination_path.mkdir(parents=True, exist_ok=True) print(f"Copying files from '{source_path}' to '{destination_path}'...") for item in source_path.rglob("*"): relative_path = item.relative_to(source_path) target_path = destination_path / relative_path if item.is_dir(): target_path.mkdir(parents=True, exist_ok=True) else: target_path.parent.mkdir(parents=True, exist_ok=True) shutil.copy2(item, target_path) print(f"Finished copying files from '{source_path}' to '{destination_path}'")