Skill-BidCreater/scripts/compose_bid_docx.py
2026-03-09 22:20:38 +08:00

36 lines
1.3 KiB
Python

from __future__ import annotations
import argparse
from pathlib import Path
from common import ensure_output_layout, get_bundle_bid_docx_path, get_bundle_content_path, normalize_bundle
from render_bid_docx import build_docx
from common import read_json
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--project", required=True)
parser.add_argument("--content")
parser.add_argument("--out")
parser.add_argument("--bundle")
args = parser.parse_args()
project_dir = Path(args.project).resolve()
output_layout = ensure_output_layout(project_dir)
bundle = normalize_bundle(args.bundle)
content_path = Path(args.content).resolve() if args.content else (
get_bundle_content_path(output_layout, bundle) if bundle else output_layout["work"] / "final_bid_content.json"
)
if not content_path.exists():
raise FileNotFoundError(f"未找到正文事实源: {content_path}。正文节点内容应由 AI 按已定稿目录填写,然后再调用本脚本渲染。")
out_path = Path(args.out).resolve() if args.out else (
get_bundle_bid_docx_path(output_layout, bundle) if bundle else output_layout["final"] / "投标文件.docx"
)
build_docx(read_json(content_path), out_path)
if __name__ == "__main__":
main()