From 47489236dcf5ae01adee17b01e36cc9a08aff538 Mon Sep 17 00:00:00 2001
From: Alexandre Duret-Lutz
Date: Mon, 2 Feb 2004 20:11:31 +0000
Subject: [PATCH] * wrap/python/cgi/ltl2tgba.in (render_dot, render_automaton)
(render_bdd): New functions, extracted from the rest of the code.
---
ChangeLog | 3 ++
wrap/python/cgi/ltl2tgba.in | 66 ++++++++++++++++---------------------
2 files changed, 31 insertions(+), 38 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9ee7d42ea..6b5b6c34b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2004-02-02 Alexandre Duret-Lutz
+ * wrap/python/cgi/ltl2tgba.in (render_dot, render_automaton)
+ (render_bdd): New functions, extracted from the rest of the code.
+
* wrap/python/cgi/ltl2tgba.in (default_translator): Default
to trans_fm.
(translators): Show trans_fm before trans_lacim.
diff --git a/wrap/python/cgi/ltl2tgba.in b/wrap/python/cgi/ltl2tgba.in
index 98fed6924..329c5f34d 100644
--- a/wrap/python/cgi/ltl2tgba.in
+++ b/wrap/python/cgi/ltl2tgba.in
@@ -1,5 +1,5 @@
#!@PYTHON@
-# -*- python -*-
+# -*- mode: python; coding: iso-8859-1 -*-
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
# et Marie Curie.
@@ -71,6 +71,25 @@ def print_stats(automaton):
print "
"
sys.stdout.flush()
+def render_dot(basename):
+ os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
+ basename + '.gif', basename + '.dot')
+ os.spawnlp(os.P_WAIT, 'convert', 'convert',
+ basename + '.gif', basename + '.png')
+ print '
'
+
+def render_automaton(basename, automata):
+ outfile = spot.ofstream(basename + '.dot')
+ spot.dotty_reachable(outfile, automata)
+ del outfile
+ render_dot(basename)
+
+def render_bdd(basename, dictionary, bdd):
+ outfile = spot.ofstream(basename + '.dot')
+ spot.bdd_print_dot(outfile, dictionary, bdd)
+ del outfile
+ render_dot(basename)
+
print "Content-Type: text/html"
print
@@ -214,15 +233,7 @@ if show_automaton_dot:
print ''; sys.stdout.flush()
if show_automaton_gif:
- outfile = spot.ofstream(imgprefix + '-a.dot')
- spot.dotty_reachable(outfile, automaton)
- del outfile
- os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
- imgprefix + '-a.gif', imgprefix + '-a.dot')
- os.spawnlp(os.P_WAIT, 'convert', 'convert',
- imgprefix + '-a.gif', imgprefix + '-a.png')
- print '
'
-
+ render_automaton(imgprefix + '-a', automaton)
if show_degen_dot or show_degen_gif:
print 'Degeneralized automaton
'
@@ -236,14 +247,7 @@ if show_degen_dot or show_degen_gif:
del s
print ''; sys.stdout.flush()
if show_degen_gif:
- outfile = spot.ofstream(imgprefix + '-d.dot')
- spot.dotty_reachable(outfile, degen)
- del outfile
- os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
- imgprefix + '-d.gif', imgprefix + '-d.dot')
- os.spawnlp(os.P_WAIT, 'convert', 'convert',
- imgprefix + '-d.gif', imgprefix + '-d.png')
- print '
'
+ render_automaton(imgprefix + '-d', degen)
else:
degen = 0
@@ -264,35 +268,21 @@ if (type(automaton) == spot.tgba_bdd_concretePtr
escaped_print_set(automaton.get_dict(),
automaton.get_core_data().relation)
if show_relation_gif:
- outfile = spot.ofstream(imgprefix + '-b.dot')
- spot.bdd_print_dot(outfile, automaton.get_dict(),
- automaton.get_core_data().relation)
- del outfile
- os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
- imgprefix + '-b.gif', imgprefix + '-b.dot')
- os.spawnlp(os.P_WAIT, 'convert', 'convert',
- imgprefix + '-b.gif', imgprefix + '-b.png')
- print '
'
+ render_bdd(imgprefix + '-b', automaton.get_dict(),
+ automaton.get_core_data().relation)
if (type(automaton) == spot.tgba_bdd_concretePtr
and (show_acceptance_dot or show_acceptance_set or show_acceptance_gif)):
print 'Acceptance relation
'
if show_acceptance_dot:
escaped_print_dot(automaton.get_dict(),
- automaton.get_core_data().accepting_conditions)
+ automaton.get_core_data().acceptance_conditions)
if show_acceptance_set:
escaped_print_set(automaton.get_dict(),
- automaton.get_core_data().accepting_conditions)
+ automaton.get_core_data().acceptance_conditions)
if show_acceptance_gif:
- outfile = spot.ofstream(imgprefix + '-c.dot')
- spot.bdd_print_dot(outfile, automaton.get_dict(),
- automaton.get_core_data().accepting_conditions)
- del outfile
- os.spawnlp(os.P_WAIT, 'dot', 'dot', '-Tgif', '-Gsize=14,14', '-o',
- imgprefix + '-c.gif', imgprefix + '-c.dot')
- os.spawnlp(os.P_WAIT, 'convert', 'convert',
- imgprefix + '-c.gif', imgprefix + '-c.png')
- print '
'
+ render_bdd(imgprefix + '-c', automaton.get_dict(),
+ automaton.get_core_data().acceptance_conditions)
if show_lbtt:
print 'LBTT conversion
'