Exploring thirty party code with leo

10 views
Skip to first unread message

TNick

unread,
Nov 21, 2011, 1:44:15 PM11/21/11
to leo-e...@googlegroups.com
Hello!

I'm a new user of Leo. Until I find proper ways to get informations about Leo without posting in the mail list have patience with me, please. :)

Was thinking about ways to use Leo and one of those is to make sense of the code written by others. I seem to recall reading about this topic somewhere, but can't seem to find it again. So, with the scripting capabilities in mind, I went to this quest as follows:

@language python


import fnmatch
import os

# the path to scan
rootPath = '/home/tnick/kit/ThirdyPartyCode/octave/octave-3.4.3/src'

# patterns for files to be scanned (a list, maybe? :)
pattern1 = '*.cc'
pattern2 = '*.h'


# locate the node where results shall be deposited
for p in c.all_positions():
    if (p.h == 'files'):
        break;

# todo: clean the node (how?)

# recursive search for files
for root, dirs, files in os.walk(rootPath):
    for filename in fnmatch.filter(files, pattern1):
        print( os.path.join(root, filename))
        child = p.insertAsLastChild()
        child.h = "@auto " + os.path.join(root, filename);
    for filename in fnmatch.filter(files, pattern2):
        print( os.path.join(root, filename))
        child = p.insertAsLastChild()
        child.h = "@auto " + os.path.join(root, filename);

# todo: nodes in p shall now be iterated and "reload-from-disk" applied to them


Is there a better way? How should I go about the todo's?
 
Thanks.

Brian Theado

unread,
Nov 21, 2011, 8:18:53 PM11/21/11
to leo-e...@googlegroups.com
On Mon, Nov 21, 2011 at 1:44 PM, TNick <nicu....@gmail.com> wrote:
> Was thinking about ways to use Leo and one of those is to make sense of the
> code written by others.
[...]

It looks like you are trying to recursively "slurp" files into @auto
nodes? I haven't used the 'projectwizard' plugin, but its docstring
describes something similar.

Brian

Terry Brown

unread,
Nov 21, 2011, 8:31:43 PM11/21/11
to leo-e...@googlegroups.com

active_path plugin also does that sort of thing.

Cheers -Terry

Edward K. Ream

unread,
Nov 21, 2011, 10:07:34 PM11/21/11
to leo-e...@googlegroups.com
On Mon, Nov 21, 2011 at 12:44 PM, TNick <nicu....@gmail.com> wrote:
> Hello!
>
> I'm a new user of Leo. Until I find proper ways to get informations about
> Leo without posting in the mail list have patience with me, please. :)

I use the "Recursive import script" in scripts.leo, the node::

Important-->Recursive import script

You can change the root path and the extensions of the files to be imported.

Edward

Bulletproof Monk

unread,
Nov 22, 2011, 1:24:50 AM11/22/11
to leo-e...@googlegroups.com
Right. Search the scripts. Search the plug-ins. Got it.

:)

Thanks.
Reply all
Reply to author
Forward
0 new messages