1#!/usr/bin/env python3 2# SPDX-License-Identifier: GPL-2.0-or-later 3# SPDX-FileCopyrightText: 2024-2025 Yamada, M. 4 5import sys, subprocess, tempfile, os, networkx as nx 6from pathlib import Path 7from miz_parser import parse_mizar # 解析だけ借用 8 9def main(): 10 if len(sys.argv) != 2: 11 sys.exit("usage: miz2svg.py <file.miz>") 12 miz = Path(sys.argv[1]).resolve() 13 G = parse_mizar(miz) 14 dot = nx.nx_pydot.to_pydot(G).to_string() 15 16 with tempfile.NamedTemporaryFile('w+', delete=False, suffix='.dot') as f: 17 f.write(dot); dot_path = f.name 18 try: 19 svg = subprocess.check_output(['dot', '-Tsvg', dot_path]) 20 sys.stdout.buffer.write(svg) # ← stdout に SVG 21 finally: 22 os.remove(dot_path) 23 24if __name__ == '__main__': main() 25