示例#1
0
def process(filesOrDirectories, excluded, inputDict=None, verbose=False):
    """
    Visit every package in ``filesOrDirectories`` and return a ModuleDict for everything,
    that can be used to generate a PYSMELLTAGS file.

    filesOrDirectories: list of paths to process. They can either be directories or files.
                        Directories can either be packages or they can contain packages.

    excluded: list of directories to exclude (eg. ['test', '.svn'])

    inputDict: a ModuleDict instance to update with any new or updated python
               namespaces.

    verbose: flag that turns on verbose logging (print what is going on).

    returns: The generated ModuleDict instance for the directories provided in
             ``filesOrDirectories``.
    """
    modules = ModuleDict()
    if inputDict:
        modules.update(inputDict)
    for rootPackage in filesOrDirectories:
        if os.path.isdir(rootPackage):
            for path, dirs, files in os.walk(rootPackage):
                for exc in excluded:
                    if exc in dirs:
                        if verbose:
                            print 'removing', exc, 'in', path
                        dirs.remove(exc)
                for f in files:
                    if not f.endswith(".py"):
                        continue
                    #path here is relative, make it absolute
                    absPath = os.path.abspath(path)
                    if verbose:
                        print 'processing', absPath, f
                    newmodules = processFile(f, absPath)
                    modules.update(newmodules)
        else: # single file
            filename = rootPackage
            absPath, filename = os.path.split(filename)
            if not absPath:
                absPath = os.path.abspath(".")
            else:
                absPath = os.path.abspath(absPath)
                
            #path here is absolute
            if verbose:
                print 'processing', absPath, filename
            newmodules = processFile(filename, absPath)
            modules.update(newmodules)
            
    return modules
示例#2
0
def process(filesOrDirectories, excluded, inputDict=None, verbose=False):
    """
    Visit every package in ``filesOrDirectories`` and return a ModuleDict for everything,
    that can be used to generate a PYSMELLTAGS file.

    filesOrDirectories: list of paths to process. They can either be directories or files.
                        Directories can either be packages or they can contain packages.

    excluded: list of directories to exclude (eg. ['test', '.svn'])

    inputDict: a ModuleDict instance to update with any new or updated python
               namespaces.

    verbose: flag that turns on verbose logging (print what is going on).

    returns: The generated ModuleDict instance for the directories provided in
             ``filesOrDirectories``.
    """
    modules = ModuleDict()
    if inputDict:
        modules.update(inputDict)
    for rootPackage in filesOrDirectories:
        if os.path.isdir(rootPackage):
            for path, dirs, files in os.walk(rootPackage):
                for exc in excluded:
                    if exc in dirs:
                        if verbose:
                            print 'removing', exc, 'in', path
                        dirs.remove(exc)
                for f in files:
                    if not f.endswith(".py"):
                        continue
                    #path here is relative, make it absolute
                    absPath = os.path.abspath(path)
                    if verbose:
                        print 'processing', absPath, f
                    newmodules = processFile(f, absPath)
                    modules.update(newmodules)
        else:  # single file
            filename = rootPackage
            absPath, filename = os.path.split(filename)
            if not absPath:
                absPath = os.path.abspath(".")
            else:
                absPath = os.path.abspath(absPath)

            #path here is absolute
            if verbose:
                print 'processing', absPath, filename
            newmodules = processFile(filename, absPath)
            modules.update(newmodules)

    return modules
示例#3
0
文件: tags.py 项目: skeept/dotvim
def process(argList, excluded, output, verbose=False):
    modules = ModuleDict()
    for rootPackage in argList:
        if os.path.isdir(rootPackage):
            for path, dirs, files in os.walk(rootPackage):
                for exc in excluded:
                    if exc in dirs:
                        if verbose:
                            print 'removing', exc, 'in', path
                        dirs.remove(exc)
                if rootPackage == '.':
                    rootPackage = os.path.split(os.getcwd())[-1]
                for f in files:
                    if not f.endswith(".py"):
                        continue
                    #path here is relative, make it absolute
                    absPath = os.path.abspath(path)
                    if verbose:
                        print 'processing', absPath, f
                    newmodules = processFile(f, absPath, rootPackage)
                    modules.update(newmodules)
        else: # single file
            filename = rootPackage
            absPath, filename = os.path.split(filename)
            rootPackageList = findRootPackageList(os.getcwd(), filename)
            if not absPath:
                absPath = os.path.abspath(".")
            else:
                absPath = os.path.abspath(absPath)
                
            #path here is absolute
            if verbose:
                print 'processing', absPath, filename
            newmodules = processFile(filename, absPath, rootPackageList[0])
            modules.update(newmodules)
            
    generateClassTag(modules, output)
示例#4
0
文件: tags.py 项目: bamanzi/site-lisp
def process(argList, excluded, output, inputDict=None, verbose=False):
    modules = ModuleDict()
    if inputDict:
        modules.update(inputDict)
    for rootPackage in argList:
        if os.path.isdir(rootPackage):
            for path, dirs, files in os.walk(rootPackage):
                for exc in excluded:
                    if exc in dirs:
                        if verbose:
                            print 'removing', exc, 'in', path
                        dirs.remove(exc)
                for f in files:
                    if not f.endswith(".py"):
                        continue
                    #path here is relative, make it absolute
                    absPath = os.path.abspath(path)
                    if verbose:
                        print 'processing', absPath, f
                    newmodules = processFile(f, absPath)
                    modules.update(newmodules)
        else:  # single file
            filename = rootPackage
            absPath, filename = os.path.split(filename)
            if not absPath:
                absPath = os.path.abspath(".")
            else:
                absPath = os.path.abspath(absPath)

            #path here is absolute
            if verbose:
                print 'processing', absPath, filename
            newmodules = processFile(filename, absPath)
            modules.update(newmodules)

    generateClassTag(modules, output)