diff --git a/IPython/Extensions/ipy_leo.py b/IPython/Extensions/ipy_leo.py index 414c3bb..a30b167 100644 --- a/IPython/Extensions/ipy_leo.py +++ b/IPython/Extensions/ipy_leo.py @@ -234,31 +234,18 @@ def eval_body(body): val = IPython.genutils.SList(body.splitlines()) return val -def push_variable(p,varname): - try: - val = eval_node(LeoNode(p)) - except: - - body = p.bodyString() - val = IPython.genutils.SList(body.splitlines()) - - ip.user_ns[varname] = val - es('ipy var: %s' % (varname,)) - def push_plain_python(p): script = g.getScript(c,p,useSelectedText=False,forcePythonSentinels=False,useSentinels=False) - exec script in ip.user_ns + try: + exec script in ip.user_ns + except: + print " -- Exception in script:\n"+script + "\n --" + raise es('ipy plain: %s' % (p.headString(),)) def push_from_leo(p): nod = LeoNode(p) h = p.headString() - tup = h.split(None,1) - # @ipy foo is variable foo - if len(tup) == 2 and tup[0] == '@ipy': - varname = tup[1] - push_variable(p,varname) - return if h.endswith('P'): push_plain_python(p) return @@ -324,8 +311,11 @@ def show_welcome(): def run_leo_startup_node(): p = g.findNodeAnywhere(c,'@ipy-startup') if p: - print "Running @ipy-startup" - push_script(p) + print "Running @ipy-startup nodes" + for n in LeoNode(p): + push_from_leo(n.p) + + run_leo_startup_node() show_welcome() diff --git a/doc/examples/leo_bridge_demo.leo b/doc/examples/leo_bridge_demo.leo index 5bdfd82..246a91a 100644 --- a/doc/examples/leo_bridge_demo.leo +++ b/doc/examples/leo_bridge_demo.leo @@ -3,7 +3,7 @@ - + @@ -12,11 +12,11 @@ @chapters @ipy-startup b -Some classes P +Some classes P File-like access csv data String list -slist to leo +slist to leo Class tests @@ -25,15 +25,15 @@ rfile strlist -Direct variables +Direct variables bar ? -# this stuff will be pushed at ipython bridge startup +?Direct children of this node will be pushed at ipython bridge startup -@others +This node itself will *not* be pushed print "world" def rfile(body,n): """ @cl rfile @@ -66,7 +66,7 @@ lines should be readable - +@others def csvdata(body,n): import csv d = csv.Sniffer().sniff(body) @@ -90,7 +90,8 @@ on many lines -@ipy_leo.format_for_leo.when_type(IPython.genutils.SList) +import ipy_leo +@ipy_leo.format_for_leo.when_type(IPython.genutils.SList) def format_slist(obj): return "@cl slist\n" + obj.n