From: timv Date: Thu, 13 Dec 2012 18:53:15 +0000 (-0500) Subject: tweaks to python code. X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=2142b8d05778e62af2fa7d1d6646067fdf4fa26d;p=dyna2 tweaks to python code. --- diff --git a/bin/prototype.py b/bin/prototype.py index bc45fcd..23c670e 100644 --- a/bin/prototype.py +++ b/bin/prototype.py @@ -100,12 +100,12 @@ class Hypergraph(object): print >> f, '}' - print 'wrote', dot, 'compiling...' +# print 'wrote', dot, 'compiling...' # run graphviz to produce image assert 0 == os.system('(dot -Tsvg %s > %s)' % (dot, svg)), 'graphviz failed.' - print 'created', svg +# print 'created', svg with file(svg) as f: return f.read() diff --git a/bin/stdlib.py b/bin/stdlib.py index 2b4726d..f2f904a 100644 --- a/bin/stdlib.py +++ b/bin/stdlib.py @@ -284,8 +284,12 @@ def go(): with file(dyna + '.chart', 'wb') as f: dump_charts(f) +try: + [dyna] = sys.argv[1:] +except ValueError: + print 'Dyna interpreter:\n\tplease specify a source file.' + sys.exit(1) -[dyna] = sys.argv[1:] cmd = """ghc -isrc Dyna.Backend.Python -e 'processFile "%s"' """ % dyna assert 0 == os.system(cmd), 'command failed:\n\t' + cmd @@ -360,7 +364,4 @@ for _fn in chart: except: pass -#def phrase(A,I,K): -# return chart['phrase/3'] - from IPython import embed; embed()