Files
FlexibleTestPlatform/backend/planner/planning_agent/utils/io_utils.py
2026-02-05 16:25:52 +08:00

15 lines
401 B
Python

from pathlib import Path
import json
def read_text(path: str) -> str:
p = Path(path)
if not p.exists():
raise FileNotFoundError(path)
return p.read_text(encoding="utf-8")
def write_json(path: str, data: dict):
p = Path(path)
p.parent.mkdir(parents=True, exist_ok=True)
with p.open("w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)