]> hydra-www.ietfng.org Git - dyna2/commitdiff
tweaks.
authortimv <tim.f.vieira@gmail.com>
Wed, 12 Jun 2013 16:50:33 +0000 (12:50 -0400)
committertimv <tim.f.vieira@gmail.com>
Wed, 12 Jun 2013 16:50:33 +0000 (12:50 -0400)
src/Dyna/Backend/Python/graph.py
src/Dyna/Backend/Python/interpreter.py
src/Dyna/Backend/Python/repl.py

index edd64ae8898b25018f2639e627c9cd294bfd77e2..f69cd2d191ce50a6f9d8b9f8d4e99687468630f1 100644 (file)
@@ -36,4 +36,5 @@ def animate(interp):
     print 'wrote examples/force.dyna.mp4'
 
 
-animate(interp)
+def main(interp):
+    animate(interp)
index 38247ba489b80f4ce4192506c59134e1211be92b..ac2d8cd86346f60967a815d5db3f9d6db38d7d73 100644 (file)
@@ -558,14 +558,20 @@ def main():
     parser.add_argument('-o', dest='output', help='Output chart.')
     parser.add_argument('--draw', action='store_true',
                         help='Output html page with hypergraph and chart.')
-    parser.add_argument('--postprocess', type=file,
-                        help='run post-processing script.')
+    parser.add_argument('--postprocess', help='run post-processing script.')
 
     parser.add_argument('--profile', action='store_true',
                         help='run profiler.')
 
     args = parser.parse_args()
 
+    if args.postprocess is not None:
+        try:
+            pp =__import__(args.postprocess)
+        except ImportError:
+            print ('ERROR: No postprocessor named %r' % args.postprocess)
+            return
+
     interp = Interpreter()
 
     if args.profile:
@@ -638,7 +644,8 @@ def main():
 
     if args.postprocess is not None:
         # TODO: import and call main method instead.
-        execfile(args.postprocess.name, {'interp': interp})
+        pp.main(interp)
+
 
 
 if __name__ == '__main__':
index a3ea9b76279531a02aff8133cb58b6da40664a7c..046adc765af9999c16a5ce696fa4d1192e433a1a 100644 (file)
@@ -112,7 +112,7 @@ class REPL(cmd.Cmd, object):
             changed = self.interp.do(src)        # throws AggregatorConflict
 
         except (AggregatorConflict, DynaInitializerException, DynaCompilerError) as e:
-            print type(e), ':'
+            print type(e).__name__ + ':'
             print e
             print '> new rule(s) were not added to program.'