#!/usr/bin/env python3 import json import sys import os import subprocess from pathlib import Path def main(): if len(sys.argv) > 1: if sys.argv[1] == "supports": sys.exit(0) sys.exit(1) out = sys.stdout sys.stdout = sys.stderr context, book = json.load(sys.stdin) src: Path = Path(context["root"]) / context["config"]["book"]["src"] for root, dirs, files in os.walk(src): for file in files: file = Path(root) / file if file.suffix == ".dia": out_file = file.with_suffix(".dia.svg") subprocess.run(["dia", "-n", "-e", out_file, file], check=True) print(json.dumps(book), file=out) if __name__ == "__main__": main()