36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
|
|
from common import ensure_output_layout, get_bundle_outline_docx_path, get_bundle_outline_path, normalize_bundle
|
|
from render_outline_docx import build_docx
|
|
from common import read_json
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--project", required=True)
|
|
parser.add_argument("--outline")
|
|
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)
|
|
outline_path = Path(args.outline).resolve() if args.outline else (
|
|
get_bundle_outline_path(output_layout, bundle) if bundle else output_layout["work"] / "final_outline.json"
|
|
)
|
|
if not outline_path.exists():
|
|
raise FileNotFoundError(f"未找到目录事实源: {outline_path}。目录判断应由 AI 完成,然后再调用本脚本渲染。")
|
|
|
|
out_path = Path(args.out).resolve() if args.out else (
|
|
get_bundle_outline_docx_path(output_layout, bundle) if bundle else output_layout["final"] / "投标文件_目录版.docx"
|
|
)
|
|
build_docx(read_json(outline_path), out_path)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|