On Mon, Mar 1, 2010 at 12:50 PM, tfer <[email protected]> wrote:
> I want to get leo to slurp inboth the .10 and trunk branches of
> IPython...

> I figure my best bet is probably to list out the directories to a text
> file, edit that and then import as "flattened outline", then once it
> gets into leo, change all the @autos to @thin or even @shadow so any
> fixes could latter be pushed to the IPython project.
>
> Any words of wisdom from people who have tackled similar things?

Use a recursive import script.  My latest version of the script is in
the new-pylint branch.

https://code.launchpad.net/~edreamleo/+junk/new-pylint

It's in new-pylint.leo

Edward

P.S.  You might try copying and pasting it:


<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet ekr_test?>
<leo_file>
<leo_header file_format="2"/>
<vnodes>
<v t="ekr.20100212224846.10601"><vh>Recursive import script</vh>
<v t="ekr.20100212224846.10602"><vh>importFiles</vh></v>
<v t="ekr.20100213083546.4253"><vh>importOneFile</vh></v>
<v t="ekr.20100212224846.10603"><vh>importDir</vh></v>
<v t="ekr.20100212224846.10604"><vh>createLastChildOf</vh></v>
</v>
</vnodes>
<tnodes>
<t tx="ekr.20100212224846.10601"># An example of running this script:

import os

@others

# theDir = 
r"C:\Python26\Lib\site-packages\logilab_astng-0.19.3-py2.6.egg\logilab\astng"
# theDir = r"C:\Python26\Lib\lib2to3"
theDir = r"C:\Python31\Lib\site-packages\coverage"

root = c.p.insertAfter()
root.setHeadString('imported files')
c.selectPosition(root)

try:
    if 0: # import a list of files.
        table = (
            r"C:\Python26\Tools\Scripts\2to3.py",
            # r"C:\Python26\Lib\bdb.py",
            # r"C:\Python26\Lib\pdb.py",
        )
        for fn in table:
            importOneFile(fn)
    else:
        # import an entire directory.
        types = (".py",)
        importFiles(theDir,types,recursive=True)
finally:
    c.redraw()

g.es("done",color="blue")
</t>
<t tx="ekr.20100212224846.10602">def importFiles
(theDir,theType=None,recursive=False):

    p = c.p

    if not g.os_path_exists(theDir):
        return g.es("directory does not exist: " + theDir)

    kind = '@file' # '@thin' does not work well.
    importDir(theDir,theType,kind,recursive,c.p)
</t>
<t tx="ekr.20100212224846.10603">def importDir (dir,types,kind,recursive,root):

    g.es("dir: " + dir,color="blue")

    try:
        files = os.listdir(dir)
        files2 = [] ; dirs =[]
        for f in files:
            path = g.os_path_join(dir,f)
            if g.os_path_isfile(path):
                name, ext = g.os_path_splitext(f)
                if not types or ext in types:
                    files2.append(path)
            elif recursive:
                dirs.append(path)
        if len(files2) &gt; 0 or len(dirs) &gt; 0:
            child = createLastChildOf(root,dir)
            c.selectVnode(child)
        if len(files2) &gt; 0:
            c.importCommands.importFilesCommand(files2,kind)
        if len(dirs) &gt; 0:
            dirs.sort()
            for dir in dirs:
                importDir(dir,types,kind,recursive,child)
    except:
        g.es("exception in importFiles script")
        g.es_exception()
</t>
<t tx="ekr.20100212224846.10604">def createLastChildOf (p,headline):

    child = p.insertAsLastChild()
    child.initHeadString(headline)
    return child
</t>
<t tx="ekr.20100213083546.4253">def importOneFile (fn):

    theDir,basename = g.os_path_split(fn)

    if g.os_path_exists(theDir):
        c.importCommands.importFilesCommand([fn],'@file')
            # '@thin' does not work well.
    else:
        g.es("directory does not exist: " + theDir)
</t>
</tnodes>
</leo_file>

EKR

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to