Show More
@@ -234,31 +234,18 b' def eval_body(body):' | |||||
234 | val = IPython.genutils.SList(body.splitlines()) |
|
234 | val = IPython.genutils.SList(body.splitlines()) | |
235 | return val |
|
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 | def push_plain_python(p): |
|
237 | def push_plain_python(p): | |
249 | script = g.getScript(c,p,useSelectedText=False,forcePythonSentinels=False,useSentinels=False) |
|
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 | es('ipy plain: %s' % (p.headString(),)) |
|
244 | es('ipy plain: %s' % (p.headString(),)) | |
252 |
|
245 | |||
253 | def push_from_leo(p): |
|
246 | def push_from_leo(p): | |
254 | nod = LeoNode(p) |
|
247 | nod = LeoNode(p) | |
255 | h = p.headString() |
|
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 | if h.endswith('P'): |
|
249 | if h.endswith('P'): | |
263 | push_plain_python(p) |
|
250 | push_plain_python(p) | |
264 | return |
|
251 | return | |
@@ -324,8 +311,11 b' def show_welcome():' | |||||
324 | def run_leo_startup_node(): |
|
311 | def run_leo_startup_node(): | |
325 | p = g.findNodeAnywhere(c,'@ipy-startup') |
|
312 | p = g.findNodeAnywhere(c,'@ipy-startup') | |
326 | if p: |
|
313 | if p: | |
327 | print "Running @ipy-startup" |
|
314 | print "Running @ipy-startup nodes" | |
328 | push_script(p) |
|
315 | for n in LeoNode(p): | |
|
316 | push_from_leo(n.p) | |||
|
317 | ||||
|
318 | ||||
329 |
|
319 | |||
330 | run_leo_startup_node() |
|
320 | run_leo_startup_node() | |
331 | show_welcome() |
|
321 | show_welcome() |
@@ -3,7 +3,7 b'' | |||||
3 | <leo_file> |
|
3 | <leo_file> | |
4 | <leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/> |
|
4 | <leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/> | |
5 | <globals body_outline_ratio="0.5"> |
|
5 | <globals body_outline_ratio="0.5"> | |
6 |
<global_window_position top=" |
|
6 | <global_window_position top="161" left="139" height="621" width="1280"/> | |
7 | <global_log_window_position top="0" left="0" height="0" width="0"/> |
|
7 | <global_log_window_position top="0" left="0" height="0" width="0"/> | |
8 | </globals> |
|
8 | </globals> | |
9 | <preferences/> |
|
9 | <preferences/> | |
@@ -12,11 +12,11 b'' | |||||
12 | <v t="vivainio.20080218184525"><vh>@chapters</vh></v> |
|
12 | <v t="vivainio.20080218184525"><vh>@chapters</vh></v> | |
13 | <v t="vivainio.20080218184540" a="E"><vh>@ipy-startup</vh> |
|
13 | <v t="vivainio.20080218184540" a="E"><vh>@ipy-startup</vh> | |
14 | <v t="vivainio.20080218184613.1"><vh>b</vh></v> |
|
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 | <v t="vivainio.20080218190816"><vh>File-like access</vh></v> |
|
16 | <v t="vivainio.20080218190816"><vh>File-like access</vh></v> | |
17 | <v t="vivainio.20080218200106"><vh>csv data</vh></v> |
|
17 | <v t="vivainio.20080218200106"><vh>csv data</vh></v> | |
18 | <v t="vivainio.20080219225120"><vh>String list</vh></v> |
|
18 | <v t="vivainio.20080219225120"><vh>String list</vh></v> | |
19 |
<v t="vivainio.20080219230342" |
|
19 | <v t="vivainio.20080219230342"><vh>slist to leo</vh></v> | |
20 | </v> |
|
20 | </v> | |
21 | </v> |
|
21 | </v> | |
22 | <v t="vivainio.20080218195413"><vh>Class tests</vh> |
|
22 | <v t="vivainio.20080218195413"><vh>Class tests</vh> | |
@@ -25,15 +25,15 b'' | |||||
25 | <v t="vivainio.20080218195413.1"><vh>rfile</vh></v> |
|
25 | <v t="vivainio.20080218195413.1"><vh>rfile</vh></v> | |
26 | <v t="vivainio.20080219225804"><vh>strlist</vh></v> |
|
26 | <v t="vivainio.20080219225804"><vh>strlist</vh></v> | |
27 | </v> |
|
27 | </v> | |
28 |
<v t="vivainio.20080218201219" |
|
28 | <v t="vivainio.20080218201219"><vh>Direct variables</vh> | |
29 | <v t="vivainio.20080218201219.2" a="E"><vh>bar</vh></v> |
|
29 | <v t="vivainio.20080218201219.2" a="E"><vh>bar</vh></v> | |
30 | </v> |
|
30 | </v> | |
31 | </vnodes> |
|
31 | </vnodes> | |
32 | <tnodes> |
|
32 | <tnodes> | |
33 | <t tx="vivainio.20080218184525">?</t> |
|
33 | <t tx="vivainio.20080218184525">?</t> | |
34 |
<t tx="vivainio.20080218184540"> |
|
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 | <t tx="vivainio.20080218184613.1">print "world"</t> |
|
37 | <t tx="vivainio.20080218184613.1">print "world"</t> | |
38 | <t tx="vivainio.20080218190816">def rfile(body,n): |
|
38 | <t tx="vivainio.20080218190816">def rfile(body,n): | |
39 | """ @cl rfile |
|
39 | """ @cl rfile | |
@@ -66,7 +66,7 b' lines' | |||||
66 | should |
|
66 | should | |
67 | be |
|
67 | be | |
68 | readable </t> |
|
68 | readable </t> | |
69 | <t tx="vivainio.20080218200031"></t> |
|
69 | <t tx="vivainio.20080218200031">@others</t> | |
70 | <t tx="vivainio.20080218200106">def csvdata(body,n): |
|
70 | <t tx="vivainio.20080218200106">def csvdata(body,n): | |
71 | import csv |
|
71 | import csv | |
72 | d = csv.Sniffer().sniff(body) |
|
72 | d = csv.Sniffer().sniff(body) | |
@@ -90,7 +90,8 b' on' | |||||
90 | many |
|
90 | many | |
91 | lines |
|
91 | lines | |
92 | </t> |
|
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 | def format_slist(obj): |
|
95 | def format_slist(obj): | |
95 | return "@cl slist\n" + obj.n |
|
96 | return "@cl slist\n" + obj.n | |
96 | </t> |
|
97 | </t> |
General Comments 0
You need to be logged in to leave comments.
Login now