##// END OF EJS Templates
ipy_leo: @cl transform takes node ref in addition to body text
Ville M. Vainio -
Show More
@@ -68,7 +68,7 b' def eval_node(n):'
68
68
69 xformer = ip.ev(hd.strip())
69 xformer = ip.ev(hd.strip())
70 es('Transform w/ %s' % repr(xformer))
70 es('Transform w/ %s' % repr(xformer))
71 return xformer(rest)
71 return xformer(rest, n)
72
72
73 class LeoNode(object, UserDict.DictMixin):
73 class LeoNode(object, UserDict.DictMixin):
74 def __init__(self,p):
74 def __init__(self,p):
@@ -3,27 +3,30 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="262" left="259" height="600" width="800"/>
6 <global_window_position top="250" left="207" 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/>
10 <find_panel_settings/>
10 <find_panel_settings/>
11 <vnodes>
11 <vnodes>
12 <v t="vivainio.20080218184525"><vh>@chapters</vh></v>
12 <v t="vivainio.20080218184525"><vh>@chapters</vh></v>
13 <v t="vivainio.20080218184540" a="ET"><vh>@ipy-startup</vh>
13 <v t="vivainio.20080218184540" a="E"><vh>@ipy-startup</vh>
14 <v t="vivainio.20080218184613.1" a="V"><vh>b</vh></v>
14 <v t="vivainio.20080218184613.1"><vh>b</vh></v>
15 <v t="vivainio.20080218200031"><vh>Some classes</vh>
15 <v t="vivainio.20080218200031" a="E"><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>
19 <v t="vivainio.20080219230342" a="TV"><vh>slist to leo</vh></v>
18 </v>
20 </v>
19 </v>
21 </v>
20 <v t="vivainio.20080218195413" a="E"><vh>Class tests</vh>
22 <v t="vivainio.20080218195413"><vh>Class tests</vh>
21 <v t="vivainio.20080218200509"><vh>csvr</vh></v>
23 <v t="vivainio.20080218200509"><vh>csvr</vh></v>
22 <v t="vivainio.20080218191007"><vh>tempfile</vh></v>
24 <v t="vivainio.20080218191007"><vh>tempfile</vh></v>
23 <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>
24 </v>
27 </v>
25 <v t="vivainio.20080218201219" a="E"><vh>Direct variables</vh>
28 <v t="vivainio.20080218201219" a="E"><vh>Direct variables</vh>
26 <v t="vivainio.20080218201219.2"><vh>bar</vh></v>
29 <v t="vivainio.20080218201219.2" a="E"><vh>bar</vh></v>
27 </v>
30 </v>
28 </vnodes>
31 </vnodes>
29 <tnodes>
32 <tnodes>
@@ -32,7 +35,7 b''
32
35
33 @others</t>
36 @others</t>
34 <t tx="vivainio.20080218184613.1">print "world"</t>
37 <t tx="vivainio.20080218184613.1">print "world"</t>
35 <t tx="vivainio.20080218190816">def rfile(body):
38 <t tx="vivainio.20080218190816">def rfile(body,n):
36 """ @cl rfile
39 """ @cl rfile
37
40
38 produces a StringIO (file like obj of the rest of the body) """
41 produces a StringIO (file like obj of the rest of the body) """
@@ -40,7 +43,7 b''
40 import StringIO
43 import StringIO
41 return StringIO.StringIO(body)
44 return StringIO.StringIO(body)
42
45
43 def tmpfile(body):
46 def tmpfile(body,n):
44 """ @cl tmpfile
47 """ @cl tmpfile
45
48
46 Produces a temporary file, with node body as contents
49 Produces a temporary file, with node body as contents
@@ -64,7 +67,7 b' should'
64 be
67 be
65 readable </t>
68 readable </t>
66 <t tx="vivainio.20080218200031"></t>
69 <t tx="vivainio.20080218200031"></t>
67 <t tx="vivainio.20080218200106">def csvdata(body):
70 <t tx="vivainio.20080218200106">def csvdata(body,n):
68 import csv
71 import csv
69 d = csv.Sniffer().sniff(body)
72 d = csv.Sniffer().sniff(body)
70 reader = csv.reader(body.splitlines(), dialect = d)
73 reader = csv.reader(body.splitlines(), dialect = d)
@@ -74,6 +77,22 b' readable </t>'
74 a,b,b
77 a,b,b
75 1,2,2</t>
78 1,2,2</t>
76 <t tx="vivainio.20080218201219"></t>
79 <t tx="vivainio.20080218201219"></t>
77 <t tx="vivainio.20080218201219.2">"hello world"</t>
80 <t tx="vivainio.20080218201219.2">@cl
81 "hello world"</t>
82 <t tx="vivainio.20080219225120">import IPython.genutils
83 def slist(body,n):
84 return IPython.genutils.SList(body.splitlines())
85 </t>
86 <t tx="vivainio.20080219225804">@cl slist
87 hello
88 world
89 on
90 many
91 lines
92 </t>
93 <t tx="vivainio.20080219230342">@ipy_leo.format_for_leo.when_type(IPython.genutils.SList)
94 def format_slist(obj):
95 return "@cl slist\n" + obj.n
96 </t>
78 </tnodes>
97 </tnodes>
79 </leo_file>
98 </leo_file>
General Comments 0
You need to be logged in to leave comments. Login now