test
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 285 of file TreeCrawler.py.

Referenced by getImportTree().

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

Definition at line 293 of file TreeCrawler.py.

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

294 def getImportTree(filename,path):
295  toplevelname = packageNameFromFilename(filename)
296  # get dependencies from given file
297  globalDependencyDict = getDependenciesFromPythonFile(filename,toplevelname,path)
298 
299  # transform this flat structure in a dependency tree
300  dependencyGraph = transformIntoGraph(globalDependencyDict,toplevelname)
301  return dependencyGraph
def transformIntoGraph
Definition: TreeCrawler.py:263
def getDependenciesFromPythonFile
Definition: TreeCrawler.py:285
def packageNameFromFilename
Definition: TreeCrawler.py:29
def getImportTree
Definition: TreeCrawler.py:293
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 247 of file TreeCrawler.py.

Referenced by transformIntoGraph().

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

Definition at line 263 of file TreeCrawler.py.

References removeRecursiveLoops().

Referenced by getImportTree().

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

Variable Documentation

list TreeCrawler._stack = []

Definition at line 45 of file TreeCrawler.py.