##// END OF EJS Templates
ipy_leo: @ipy-startup children are run in sequence, not ipy_startup itself
Ville M. Vainio -
Show More
@@ -234,31 +234,18 b' def eval_body(body):'
234 234 val = IPython.genutils.SList(body.splitlines())
235 235 return val
236 236
237 def push_variable(p,varname):
238 try:
239 val = eval_node(LeoNode(p))
240 except:
241
242 body = p.bodyString()
243 val = IPython.genutils.SList(body.splitlines())
244
245 ip.user_ns[varname] = val
246 es('ipy var: %s' % (varname,))
247
248 237 def push_plain_python(p):
249 238 script = g.getScript(c,p,useSelectedText=False,forcePythonSentinels=False,useSentinels=False)
250 exec script in ip.user_ns
239 try:
240 exec script in ip.user_ns
241 except:
242 print " -- Exception in script:\n"+script + "\n --"
243 raise
251 244 es('ipy plain: %s' % (p.headString(),))
252 245
253 246 def push_from_leo(p):
254 247 nod = LeoNode(p)
255 248 h = p.headString()
256 tup = h.split(None,1)
257 # @ipy foo is variable foo
258 if len(tup) == 2 and tup[0] == '@ipy':
259 varname = tup[1]
260 push_variable(p,varname)
261 return
262 249 if h.endswith('P'):
263 250 push_plain_python(p)
264 251 return
@@ -324,8 +311,11 b' def show_welcome():'
324 311 def run_leo_startup_node():
325 312 p = g.findNodeAnywhere(c,'@ipy-startup')
326 313 if p:
327 print "Running @ipy-startup"
328 push_script(p)
314 print "Running @ipy-startup nodes"
315 for n in LeoNode(p):
316 push_from_leo(n.p)
317
318
329 319
330 320 run_leo_startup_node()
331 321 show_welcome()
@@ -3,7 +3,7 b''
3 3 <leo_file>
4 4 <leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/>
5 5 <globals body_outline_ratio="0.5">
6 <global_window_position top="250" left="207" height="621" width="1280"/>
6 <global_window_position top="161" left="139" height="621" width="1280"/>
7 7 <global_log_window_position top="0" left="0" height="0" width="0"/>
8 8 </globals>
9 9 <preferences/>
@@ -12,11 +12,11 b''
12 12 <v t="vivainio.20080218184525"><vh>@chapters</vh></v>
13 13 <v t="vivainio.20080218184540" a="E"><vh>@ipy-startup</vh>
14 14 <v t="vivainio.20080218184613.1"><vh>b</vh></v>
15 <v t="vivainio.20080218200031" a="E"><vh>Some classes P</vh>
15 <v t="vivainio.20080218200031" a="ETV"><vh>Some classes P</vh>
16 16 <v t="vivainio.20080218190816"><vh>File-like access</vh></v>
17 17 <v t="vivainio.20080218200106"><vh>csv data</vh></v>
18 18 <v t="vivainio.20080219225120"><vh>String list</vh></v>
19 <v t="vivainio.20080219230342" a="TV"><vh>slist to leo</vh></v>
19 <v t="vivainio.20080219230342"><vh>slist to leo</vh></v>
20 20 </v>
21 21 </v>
22 22 <v t="vivainio.20080218195413"><vh>Class tests</vh>
@@ -25,15 +25,15 b''
25 25 <v t="vivainio.20080218195413.1"><vh>rfile</vh></v>
26 26 <v t="vivainio.20080219225804"><vh>strlist</vh></v>
27 27 </v>
28 <v t="vivainio.20080218201219" a="E"><vh>Direct variables</vh>
28 <v t="vivainio.20080218201219"><vh>Direct variables</vh>
29 29 <v t="vivainio.20080218201219.2" a="E"><vh>bar</vh></v>
30 30 </v>
31 31 </vnodes>
32 32 <tnodes>
33 33 <t tx="vivainio.20080218184525">?</t>
34 <t tx="vivainio.20080218184540"># this stuff will be pushed at ipython bridge startup
34 <t tx="vivainio.20080218184540">?Direct children of this node will be pushed at ipython bridge startup
35 35
36 @others</t>
36 This node itself will *not* be pushed</t>
37 37 <t tx="vivainio.20080218184613.1">print "world"</t>
38 38 <t tx="vivainio.20080218190816">def rfile(body,n):
39 39 """ @cl rfile
@@ -66,7 +66,7 b' lines'
66 66 should
67 67 be
68 68 readable </t>
69 <t tx="vivainio.20080218200031"></t>
69 <t tx="vivainio.20080218200031">@others</t>
70 70 <t tx="vivainio.20080218200106">def csvdata(body,n):
71 71 import csv
72 72 d = csv.Sniffer().sniff(body)
@@ -90,7 +90,8 b' on'
90 90 many
91 91 lines
92 92 </t>
93 <t tx="vivainio.20080219230342">@ipy_leo.format_for_leo.when_type(IPython.genutils.SList)
93 <t tx="vivainio.20080219230342">import ipy_leo
94 @ipy_leo.format_for_leo.when_type(IPython.genutils.SList)
94 95 def format_slist(obj):
95 96 return "@cl slist\n" + obj.n
96 97 </t>
General Comments 0
You need to be logged in to leave comments. Login now