From 72cb6e4df846cb9681d8feaa293183b213b071a1 Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Tue, 26 Jan 2016 08:58:45 +0100 Subject: [PATCH] werkend dotscript --- a4/tcp/results/van_learnlib_naar_dot.py | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 a4/tcp/results/van_learnlib_naar_dot.py diff --git a/a4/tcp/results/van_learnlib_naar_dot.py b/a4/tcp/results/van_learnlib_naar_dot.py new file mode 100755 index 0000000..86d5e7f --- /dev/null +++ b/a4/tcp/results/van_learnlib_naar_dot.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python2 + +import sys +import re + +sys.stderr.write("""Usage: {} [INPUT [OUTPUT] +als input/output niet specificeerd pakt hij stdin/stdout +voorbeeld: +\t$ < file.dot ./van_learnlib_naar_dot.py | dot -Tpdf > file.pdf +""".format(sys.argv[0])) + +if len(sys.argv) == 1: + inputfile = sys.stdin + outputfile = sys.stdout +elif len(sys.argv) == 2: + inputfile = open(sys.argv[1], 'r') + outputfile = sys.stdout +else: + inputfile = open(sys.argv[1], 'r') + outputfile = open(sys.argv[2], 'w') + +data = [] +pat = r's(?P\d+) -> s(?P\d+) \[label="(?P\S+) / (?P\S+)"\];' + +for line in inputfile: + match = re.search(pat, line) + if match: + outputfile.write('\ts{0} -> s{0}_ [label="!{1}"]\n'.format( + match.group('f'), match.group('i'))) + outputfile.write('\ts{}_ -> s{} [label="?{}"]\n'.format( + match.group('f'), match.group('t'), match.group('o'))) + else: + outputfile.write(line) + +if inputfile != sys.stdin: + inputfile.close() +if outputfile != sys.stdout: + outputfile.close() -- 2.20.1