Initial commit
This commit is contained in:
14
backend/planner/planning_agent/utils/io_utils.py
Normal file
14
backend/planner/planning_agent/utils/io_utils.py
Normal file
@@ -0,0 +1,14 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user