From 6cd77fb6f64531a1173b76dcd8900f6195da9334 Mon Sep 17 00:00:00 2001 From: Tim Vieira Date: Fri, 28 Jun 2013 02:10:20 -0400 Subject: [PATCH] cleanup output formats. --- src/Dyna/Backend/Python/post/trace.py | 3 +-- src/Dyna/Backend/Python/repl.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Dyna/Backend/Python/post/trace.py b/src/Dyna/Backend/Python/post/trace.py index c28b8f2..10b3cd1 100644 --- a/src/Dyna/Backend/Python/post/trace.py +++ b/src/Dyna/Backend/Python/post/trace.py @@ -125,8 +125,7 @@ class Crux(object): side = ['side: ' + self.get_function(x) for x in graph.outputs if x != rule.anf.result and x != rule.anf.head] return [('%s %s' % (red % rule.anf.agg, self.values(rule.anf.result))), (green % ('# %s' % src)), - (green % ('# %s' % subst(src, user_vars))), - (green % ('# %s' % drepr(user_vars))), + (green % ('# %s where %s' % (subst(src, user_vars), drepr(user_vars)))), ('head: %s' % self.get_function(rule.anf.head)), ('result: %s' % self.get_function(rule.anf.result))] \ + side diff --git a/src/Dyna/Backend/Python/repl.py b/src/Dyna/Backend/Python/repl.py index aaa1ccc..afe0290 100644 --- a/src/Dyna/Backend/Python/repl.py +++ b/src/Dyna/Backend/Python/repl.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + """ TODO: unsubscribe @@ -173,7 +175,6 @@ class REPL(cmd.Cmd, object): # drop $out chart del self.interp.chart['$out/1'] - def do_vquery(self, q): """ See query. @@ -185,7 +186,9 @@ class REPL(cmd.Cmd, object): print 'No results.' return for val, bindings in results: - print ' ', _repr(val), 'when', drepr(dict(bindings)) + #if not bindings: + # print ' ', _repr(val) + print ' ', _repr(val), 'where', drepr(dict(bindings)) print def do_query(self, q): @@ -202,14 +205,14 @@ class REPL(cmd.Cmd, object): - `vquery` shows variable bindings :- vquery f(X) - 1 when {X=1} - 4 when {X=1} + 1 where {X=1} + 4 where {X=1} - `query` shows variable bindings applied to query :- query f(X) - 1 is f(1) - 4 is f(2) + 1 ← f(1) + 4 ← f(2) """ results = self._query(q) @@ -219,7 +222,7 @@ class REPL(cmd.Cmd, object): print 'No results.' return for term, result in sorted((subst(q, dict(result.variables)), result) for result in results): - print ' ', _repr(result.value), 'is', term + print ' ', _repr(result.value), '←', term print def default(self, line, show_changed=True): @@ -263,7 +266,7 @@ class REPL(cmd.Cmd, object): if x.value: print '%s: %s' % (i, q) for result in x.value: - print ' ', _repr(result.value), 'when', drepr(dict(result.variables)) + print ' ', _repr(result.value), 'where', drepr(dict(result.variables)) print self.interp.dump_errors() @@ -289,14 +292,14 @@ class REPL(cmd.Cmd, object): Changes ======= f(X,X): - 1 when {X=1} + 1 where {X=1} To view all subscriptions: :- subscriptions f(X): - 1 when {X=1} - 2 when {X=2} + 1 where {X=1} + 2 where {X=2} """ if line.endswith('.'): @@ -312,7 +315,7 @@ class REPL(cmd.Cmd, object): if results: print q for result in results: - print ' ', _repr(result.value), 'when', drepr(dict(result.variables)) + print ' ', _repr(result.value), 'where', drepr(dict(result.variables)) print def do_help(self, line): -- 2.50.1