##// END OF EJS Templates
ileo: wb.require() for handling inter-node dependencies
Ville M. Vainio -
Show More
@@ -12,7 +12,7 b' from IPython.ipapi import TryNext'
12 import IPython.macro
12 import IPython.macro
13 import IPython.Shell
13 import IPython.Shell
14
14
15 __leo_push_history = set()
15 _leo_push_history = set()
16
16
17 def init_ipython(ipy):
17 def init_ipython(ipy):
18 """ This will be run by _ip.load('ipy_leo')
18 """ This will be run by _ip.load('ipy_leo')
@@ -27,6 +27,8 b' def init_ipython(ipy):'
27 ip.expose_magic('mb',mb_f)
27 ip.expose_magic('mb',mb_f)
28 ip.expose_magic('lee',lee_f)
28 ip.expose_magic('lee',lee_f)
29 ip.expose_magic('leoref',leoref_f)
29 ip.expose_magic('leoref',leoref_f)
30 # Note that no other push command should EVER have lower than 0
31 expose_ileo_push(push_mark_req, -1)
30 expose_ileo_push(push_cl_node,100)
32 expose_ileo_push(push_cl_node,100)
31 # this should be the LAST one that will be executed, and it will never raise TryNext
33 # this should be the LAST one that will be executed, and it will never raise TryNext
32 expose_ileo_push(push_ipython_script, 1000)
34 expose_ileo_push(push_ipython_script, 1000)
@@ -338,6 +340,7 b' class LeoWorkbook:'
338 if re.match(cmp, node.h, re.IGNORECASE):
340 if re.match(cmp, node.h, re.IGNORECASE):
339 yield node
341 yield node
340 return
342 return
343
341 def require(self, req):
344 def require(self, req):
342 """ Used to control node push dependencies
345 """ Used to control node push dependencies
343
346
@@ -346,8 +349,9 b' class LeoWorkbook:'
346 E.g. wb.require('foo') will do wb.foo.ipush() if it hasn't been done already
349 E.g. wb.require('foo') will do wb.foo.ipush() if it hasn't been done already
347 """
350 """
348
351
349 if req not in __leo_push_history:
352 if req not in _leo_push_history:
350 getattr(self.req).ipush()
353 es('Require: ' + req)
354 getattr(self,req).ipush()
351
355
352
356
353 @IPython.generics.complete_object.when_type(LeoWorkbook)
357 @IPython.generics.complete_object.when_type(LeoWorkbook)
@@ -458,6 +462,14 b' def push_ev_node(node):'
458 res = ip.ev(expr)
462 res = ip.ev(expr)
459 node.v = res
463 node.v = res
460
464
465 def push_mark_req(node):
466 """ This should be the first one that gets called.
467
468 It will mark the node as 'pushed', for wb.require.
469 """
470 _leo_push_history.add(node.h)
471 raise TryNext
472
461
473
462 def push_position_from_leo(p):
474 def push_position_from_leo(p):
463 try:
475 try:
General Comments 0
You need to be logged in to leave comments. Login now