44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Portable project builder: finalized SVG pages and Markdown speaker notes."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
import tempfile
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--project", type=Path, required=True)
|
|
parser.add_argument("--output", type=Path, required=True)
|
|
args = parser.parse_args()
|
|
project = args.project.resolve()
|
|
sys.path.insert(0, str(project / "vendor/native-workflow/scripts"))
|
|
from native_export import export, prepare_svg, regular
|
|
import template_ref as ref
|
|
import ppt_project
|
|
|
|
config, _ = ppt_project.check(project)
|
|
ref.require(config["authoring"]["route"] == "native", "Native builder requires the native authoring route")
|
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
with tempfile.TemporaryDirectory(prefix="native-pages-", dir=args.output.parent) as temporary:
|
|
temporary = Path(temporary)
|
|
sources, notes = [], {}
|
|
for page in config["pages"]:
|
|
source = regular(project / page["source"], "page source")
|
|
target = temporary / f"{page['id']}.svg"
|
|
root = prepare_svg(source, target, project)
|
|
ref.require(root.get("data-pptx-layout") == page["layout"], "Page SVG layout differs from project.json")
|
|
sources.append(target)
|
|
notes[target.stem] = (project / page["notes"]).read_text(encoding="utf-8")
|
|
facts = export(project / config["template"]["manifest"], config["template"]["theme"],
|
|
sources, args.output, notes, project)
|
|
print(json.dumps(facts, ensure_ascii=False))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|