File size: 885 Bytes
734b5b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from __future__ import annotations
from pathlib import Path
import json, shutil
from src.core.models import JobConfig, dataclass_to_dict

class OfflineExportAgent:
    name = "export_agent"

    def run(self, final_pdf: Path, job_config: JobConfig, stages: list, log_file: Path) -> tuple[Path, Path]:
        out = job_config.output_dir
        out.mkdir(parents=True, exist_ok=True)
        dest = out / f"{job_config.input_pdf.stem}-final.pdf"
        if final_pdf.resolve() != dest.resolve():
            shutil.copy2(final_pdf, dest)
        manifest = {
            "job_config": dataclass_to_dict(job_config),
            "stages": stages,
            "final_pdf": str(dest),
            "log_file": str(log_file),
        }
        mf = out / "manifest.json"
        with mf.open("w", encoding="utf-8") as f:
            json.dump(manifest, f, indent=2)
        return dest, mf