python: add an SVG printer for automata

* wrap/python/spot.i (tgba._repr_svg_): Call dot to
output SVG using the same logic as in Vaucanson 2.
This commit is contained in:
Alexandre Duret-Lutz 2014-08-24 17:21:47 +02:00
parent ae35cc29f5
commit baf644a93a

View file

@ -326,6 +326,22 @@ namespace std {
};
}
%pythoncode %{
import subprocess
def render_automaton_as_svg(a):
dotsrc = ostringstream()
dotty_reachable(dotsrc, a)
dotty = subprocess.Popen(['dot', '-Tsvg'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
dotty.stdin.write(dotsrc.str().encode('utf-8'))
res = dotty.communicate()
return res[0].decode('utf-8')
tgba._repr_svg_ = render_automaton_as_svg
%}
%inline %{
spot::ltl::parse_error_list
empty_parse_error_list()