From: pimjager Date: Tue, 26 Jan 2016 21:42:50 +0000 (+0100) Subject: Python convertscript terug gezet, kutCharlie2 ;) X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=28eed291912cc90c398a993b5cc0a03499df2792;p=tt2015.git Python convertscript terug gezet, kutCharlie2 ;) --- 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()