]> hydra-www.ietfng.org Git - dyna2/commitdiff
tweaks/cleanup
authorTim Vieira <tim.f.vieira@gmail.com>
Sat, 20 Jul 2013 18:28:01 +0000 (14:28 -0400)
committerTim Vieira <tim.f.vieira@gmail.com>
Sat, 20 Jul 2013 18:28:01 +0000 (14:28 -0400)
src/Dyna/Backend/Python/post/draw_circuit.py
src/Dyna/Backend/Python/stdlib.py
src/Dyna/Backend/Python/utils.py

index 194c5071cd7bdbcb6650da45374dcfa0ac7263d3..71b8e8231febcad7288e09d314e8a363ce3d6890 100644 (file)
@@ -7,7 +7,6 @@ import re
 import webbrowser
 from debug import Hypergraph
 from cStringIO import StringIO
-from utils import lexer, subst
 
 HEADER = """
 <html>
index b448afb648c8c86a533917a4c8ef236c2dda48cc..100a9f97e8e7ebdede399eb9468358e0349a3073 100644 (file)
@@ -42,10 +42,8 @@ def lte(x, y):
 def eq(x,y):
     """
     My work around for discrepency in bool equality True==1 and False==0.
-
     >>> eq(true, 1)
     false
-
     >>> eq(1, 1.0)
     true
     """
@@ -61,16 +59,13 @@ _range = range
 def range(*x):
     return todyna(_range(*x))
 
-
 def split(s, delim='\s+'):
     return todyna(re.split(delim, s))
 
-
 def crash():
     class Crasher(Exception): pass
     raise Crasher('Hey, you asked for it!')
 
-
 def pycall(name, *args):
     """
     Temporary foreign function interface - call Python functions from dyna!
@@ -79,73 +74,55 @@ def pycall(name, *args):
     x = eval(name)(*args)
     return todyna(x)
 
-
 def topython(x):
-
     if islist(x):
         return [topython(y) for y in x.aslist]
-
     elif isinstance(x, MapsTo):
         return tuple(x.args)
-
     return x
 
-
 def todyna(x):
-
     if isinstance(x, (set, Counter)):
         x = list(x)
         x.sort()
         return todyna(x)
-
     elif x is True:
         return true
-
     elif x is False:
         return false
-
     elif isinstance(x, dict):
         return todyna([MapsTo(todyna(k), todyna(v)) for k,v in x.items()])
-
     elif isinstance(x, (list, tuple)):
         c = Nil
         for y in reversed(x):
             c = Cons(todyna(y), c)
         return c
     else:
-
         return x
 
-
 def get(x, i):
     return x[i]
 
-
 def getkey(m, k):
     return m[k]
 
-
 def setkey(m, k, v):
     m[k] = v
     return m
 
-
 def islist(x):
     return isinstance(x, Cons) or x is Nil
 
-
 def iter_cons(x):
     if not islist(x):
         raise TypeError("Attemping to iterate something which isn't a list. %r" % (x,))
     return x.like_chart()
 
-
 def in_list(x, a):
     if not islist(a):
         raise TypeError("Attemping to iterate something which isn't a list. %r" % (a,))
     return todyna(x in a.aslist)
 
-
 # should probably be done with memoized backchaining...
 def read_lines(filename):
     with file(filename) as f:
index 7a666dcd2f65d83bf40006fec5eac716347ac027..87824dcc8dd93293f34eaab8f3c9a84e7137cc25 100644 (file)
@@ -40,17 +40,9 @@ def isbool(x):
     return x is true or x is false
 
 
-
-
 def _repr(x):
-
-# TODO: this assertion should eventually hold.
-#    assert x is not True and x is not False, x
-    if x is True:
-        return 'true'
-    elif x is False:
-        return 'false'
-    elif x is None:
+    #assert x is not True and x is not False, x
+    if x is None:
         return 'null'
     elif isinstance(x, basestring):
         # dyna doesn't accept single-quoted strings