CMS 3D CMS Logo

Classes | Functions | Variables

TreeCrawler Namespace Reference

Classes

class  Color
class  mymf
class  Package
class  SearchHit

Functions

def getDependenciesFromPythonFile
def getImportTree
def packageNameFromFilename
def transformIntoGraph

Variables

list _stack = []

Function Documentation

def TreeCrawler::getDependenciesFromPythonFile (   filename,
  toplevelname,
  path 
)

Definition at line 151 of file TreeCrawler.py.

00152                                                              :
00153     modulefinder = mymf(path)
00154     modulefinder.run_script(filename)
00155     globalDependencyDict = modulefinder._depgraph
00156     globalDependencyDict[toplevelname] = globalDependencyDict["__main__"] 
00157     return globalDependencyDict
00158 

def TreeCrawler::getImportTree (   filename,
  path 
)

Definition at line 159 of file TreeCrawler.py.

00160                                 :
00161     toplevelname = packageNameFromFilename(filename)
00162     # get dependencies from given file
00163     globalDependencyDict = getDependenciesFromPythonFile(filename,toplevelname,path)
00164         
00165     # transform this flat structure in a dependency tree
00166     dependencyGraph = transformIntoGraph(globalDependencyDict,toplevelname)
00167     return dependencyGraph                                               
def TreeCrawler::packageNameFromFilename (   name)

Definition at line 29 of file TreeCrawler.py.

00030                                  :
00031     return ".".join(name.replace("python/","").replace(".py","").split("/")[-3:])
00032 

def TreeCrawler::transformIntoGraph (   depgraph,
  toplevel 
)

Definition at line 130 of file TreeCrawler.py.

00131                                          :
00132     packageDict = {}
00133     # create the top level config
00134     packageDict[toplevel] = Package(toplevel, top = True) 
00135 
00136     # create package objects
00137     for key, value in depgraph.iteritems():
00138         if key.count(".") == 2 and key != toplevel: 
00139             packageDict[key] = Package(key)
00140         for name in value.keys():
00141             if name.count(".") == 2: packageDict[name] = Package(name)
00142     # now create dependencies
00143     for key, value in depgraph.iteritems():
00144         if key.count(".") == 2 or key == toplevel:
00145             package = packageDict[key]
00146             package.dependencies = [packageDict[name] for name in value.keys() if name.count(".") == 2]
00147 
00148     # find and return the top level config
00149     return packageDict[toplevel]
00150 


Variable Documentation

Definition at line 45 of file TreeCrawler.py.