CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
TreeCrawler Namespace Reference

Classes

class  Color
 
class  mymf
 
class  Package
 
class  SearchHit
 

Functions

def getDependenciesFromPythonFile
 
def getImportTree
 
def packageNameFromFilename
 
def removeRecursiveLoops
 
def transformIntoGraph
 

Variables

list _stack = []
 

Function Documentation

def TreeCrawler.getDependenciesFromPythonFile (   filename,
  toplevelname,
  path 
)

Definition at line 284 of file TreeCrawler.py.

Referenced by getImportTree().

285 def getDependenciesFromPythonFile(filename,toplevelname,path):
286  modulefinder = mymf(path)
287  modulefinder.run_script(filename)
288  globalDependencyDict = modulefinder._depgraph
289  globalDependencyDict[toplevelname] = globalDependencyDict["__main__"]
290  return globalDependencyDict
291 
def getDependenciesFromPythonFile
Definition: TreeCrawler.py:284
def TreeCrawler.getImportTree (   filename,
  path 
)

Definition at line 292 of file TreeCrawler.py.

References getDependenciesFromPythonFile(), packageNameFromFilename(), and transformIntoGraph().

293 def getImportTree(filename,path):
294  toplevelname = packageNameFromFilename(filename)
295  # get dependencies from given file
296  globalDependencyDict = getDependenciesFromPythonFile(filename,toplevelname,path)
297 
298  # transform this flat structure in a dependency tree
299  dependencyGraph = transformIntoGraph(globalDependencyDict,toplevelname)
300  return dependencyGraph
def transformIntoGraph
Definition: TreeCrawler.py:262
def getDependenciesFromPythonFile
Definition: TreeCrawler.py:284
def packageNameFromFilename
Definition: TreeCrawler.py:29
def getImportTree
Definition: TreeCrawler.py:292
def TreeCrawler.packageNameFromFilename (   name)

Definition at line 29 of file TreeCrawler.py.

References join(), python.rootplot.root2matplotlib.replace(), and split.

Referenced by getImportTree(), and TreeCrawler.Package.search().

29 
30 def packageNameFromFilename(name):
31  return ".".join(name.replace("python/","").replace(".py","").split("/")[-3:])
32 
def packageNameFromFilename
Definition: TreeCrawler.py:29
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
double split
Definition: MVATrainer.cc:139
def TreeCrawler.removeRecursiveLoops (   node,
  verbose = False,
  currentStack = None 
)

Definition at line 246 of file TreeCrawler.py.

Referenced by transformIntoGraph().

247 def removeRecursiveLoops( node, verbose=False, currentStack=None ) :
248  if currentStack is None : currentStack=[]
249  try :
250  duplicateIndex=currentStack.index( node ) # If there isn't a recursive loop this will raise a ValueError
251  if verbose :
252  print "Removing recursive loop in:"
253  for index in xrange(duplicateIndex,len(currentStack)) :
254  print " ",currentStack[index].name,"-->"
255  print " ",node.name
256  currentStack[-1].dependencies.remove(node)
257  except ValueError:
258  # No recursive loop found, so continue traversing the tree
259  currentStack.append( node )
260  for subnode in node.dependencies :
261  removeRecursiveLoops( subnode, verbose, currentStack[:] )
def removeRecursiveLoops
Definition: TreeCrawler.py:246
def TreeCrawler.transformIntoGraph (   depgraph,
  toplevel 
)

Definition at line 262 of file TreeCrawler.py.

References removeRecursiveLoops().

Referenced by getImportTree().

263 def transformIntoGraph(depgraph,toplevel):
264  packageDict = {}
265  # create the top level config
266  packageDict[toplevel] = Package(toplevel, top = True)
267 
268  # create package objects
269  for key, value in depgraph.iteritems():
270  if key.count(".") == 2 and key != toplevel:
271  packageDict[key] = Package(key)
272  for name in value.keys():
273  if name.count(".") == 2: packageDict[name] = Package(name)
274  # now create dependencies
275  for key, value in depgraph.iteritems():
276  if key.count(".") == 2 or key == toplevel:
277  package = packageDict[key]
278  package.dependencies = [packageDict[name] for name in value.keys() if name.count(".") == 2]
279 
280  removeRecursiveLoops( packageDict[toplevel] )
281  # find and return the top level config
282  return packageDict[toplevel]
283 
def transformIntoGraph
Definition: TreeCrawler.py:262
def removeRecursiveLoops
Definition: TreeCrawler.py:246

Variable Documentation

list TreeCrawler._stack = []

Definition at line 45 of file TreeCrawler.py.