##// END OF EJS Templates
ileo: ...
Ville M. Vainio -
Show More
@@ -28,6 +28,7 b' def init_ipython(ipy):'
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 ip.expose_magic('lleo',lleo_f)
30 ip.expose_magic('lleo',lleo_f)
31 ip.expose_magic('lshadow', lshadow_f)
31 # Note that no other push command should EVER have lower than 0
32 # Note that no other push command should EVER have lower than 0
32 expose_ileo_push(push_mark_req, -1)
33 expose_ileo_push(push_mark_req, -1)
33 expose_ileo_push(push_cl_node,100)
34 expose_ileo_push(push_cl_node,100)
@@ -649,12 +650,85 b' def lleo_f(selg, args):'
649 lleo
650 lleo
650 """
651 """
651
652
652 import shlex, sys
653 import shlex, sys,os
653 argv = ['leo'] + shlex.split(args)
654 argv = shlex.split(args)
654 sys.argv = argv
655
656 # when run without args, leo will open ipython_notebook for
657 # quick note taking / experimentation
658
659 if not argv:
660 argv = [os.path.join(ip.options.ipythondir,'ipython_notebook.leo')]
661
662 sys.argv = ['leo'] + argv
655 # if this var exists and is true, leo will "launch" (connect)
663 # if this var exists and is true, leo will "launch" (connect)
656 # ipython immediately when it's started
664 # ipython immediately when it's started
657 global _request_immediate_connect
665 global _request_immediate_connect
658 _request_immediate_connect = True
666 _request_immediate_connect = True
659 import leo.core.runLeo
667 import leo.core.runLeo
660 leo.core.runLeo.run()
668 leo.core.runLeo.run()
669
670 def lshadow_f(self, arg):
671 """ lshadow [path]
672
673 Create shadow nodes for path (default .)
674
675 """
676 if not arg.split():
677 arg = '.'
678
679 p = c.currentPosition().insertAfter()
680 c.setCurrentPosition(p)
681 shadow_walk(arg)
682 c.redraw()
683
684
685 def shadow_walk(directory, parent=None, isroot=True):
686 """ source: http://leo.zwiki.org/CreateShadows
687
688 """
689
690 from os import listdir
691 from os.path import join, abspath, basename, normpath, isfile
692 from fnmatch import fnmatch
693
694 RELATIVE_PATHS = False
695
696 patterns_to_ignore = ['*.pyc', '*.leo', '*.gif', '*.png', '*.jpg', '*.json']
697
698 match = lambda s: any(fnmatch(s, p) for p in patterns_to_ignore)
699
700 is_ignorable = lambda s: any([ s.startswith('.'), match(s) ])
701
702 p = c.currentPosition()
703
704 if not RELATIVE_PATHS: directory = abspath(directory)
705 if isroot:
706 body = "@path %s" % normpath(directory)
707 c.setHeadString(p, body)
708 for name in listdir(directory):
709 if is_ignorable(name):
710 continue
711 path = join(directory, name)
712 if isfile(path):
713 g.es('file:', path)
714 headline = '@shadow %s' % basename(path)
715 if parent:
716 node = parent
717 else:
718 node = p
719 child = node.insertAsLastChild()
720 child.initHeadString(headline)
721 else:
722 g.es('dir:', path)
723 headline = basename(path)
724 body = "@path %s" % normpath(path)
725 if parent:
726 node = parent
727 else:
728 node = p
729 child = node.insertAsLastChild()
730 child.initHeadString(headline)
731 child.initBodyString(body)
732 shadow_walk(path, parent=child, isroot=False)
733
734
General Comments 0
You need to be logged in to leave comments. Login now