Files

17 lines
558 B
Python

from datetime import date
from pathlib import Path
class ReportWriter:
"""把人可读日报写入本地文件。"""
def __init__(self, base_dir: Path) -> None:
self.base_dir = base_dir
def write_daily_report(self, run_date: date, content_md: str) -> Path:
# 日报按日期落盘,便于人工浏览和备份。
self.base_dir.mkdir(parents=True, exist_ok=True)
report_path = self.base_dir / f"{run_date.isoformat()}.md"
report_path.write_text(content_md, encoding="utf-8")
return report_path