##// END OF EJS Templates
ipy_leo: push-to-ipython counterpart implemented
vivainio -
Show More
@@ -11,7 +11,7 b' def format_for_leo(obj):'
11 11
12 12 @format_for_leo.when_type(list)
13 13 def format_list(obj):
14 return "\n".join(str(s) for s in obj)
14 return '@ipy-type list\n' + "\n".join(str(s) for s in obj)
15 15
16 16
17 17 def add_var(self,varname):
@@ -29,11 +29,33 b' def add_var(self,varname):'
29 29 formatted = format_for_leo(val)
30 30 c.setBodyString(p2,formatted)
31 31
32 def add_file(self,fname):
33 ip = self.getapi()
34 leo = ip.user_ns['leox']
35 c,g = leo.c, leo.g
36 p2 = c.currentPosition().insertAfter()
37
38 def push_from_leo(p):
39 print "Pushed from leo",p
40 leo = ip.user_ns['leox']
41 c,g = leo.c, leo.g
42
43 script = g.getScript(c,p,useSelectedText=False,forcePythonSentinels=True,useSentinels=True)
44 script = g.splitLines(script + '\n')
45 script = ''.join(z for z in script if z.strip())
46 ip.runlines(script)
47 ip.user_ns['leox'].push = push_from_leo
48
49
50
32 51 def leo_f(self,s):
33 52 ip = self.getapi()
34 53 s = s.strip()
35 54 if s in ip.user_ns:
36 55 add_var(self,s)
56 elif os.path.isfile(s):
57 # todo open file
58 pass
37 59
38 60 ip.expose_magic('leo',leo_f)
39 61
General Comments 0
You need to be logged in to leave comments. Login now