CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 287 of file TreeCrawler.py.

Referenced by getImportTree().

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

Definition at line 295 of file TreeCrawler.py.

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

296 def getImportTree(filename,path):
297  toplevelname = packageNameFromFilename(filename)
298  # get dependencies from given file
299  globalDependencyDict = getDependenciesFromPythonFile(filename,toplevelname,path)
300 
301  # transform this flat structure in a dependency tree
302  dependencyGraph = transformIntoGraph(globalDependencyDict,toplevelname)
303  return dependencyGraph
def transformIntoGraph
Definition: TreeCrawler.py:265
def getDependenciesFromPythonFile
Definition: TreeCrawler.py:287
def packageNameFromFilename
Definition: TreeCrawler.py:31
def getImportTree
Definition: TreeCrawler.py:295
def TreeCrawler.packageNameFromFilename (   name)

Definition at line 31 of file TreeCrawler.py.

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

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

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

Definition at line 249 of file TreeCrawler.py.

References print(), and sistrip::SpyUtilities.range().

Referenced by transformIntoGraph().

250 def removeRecursiveLoops( node, verbose=False, currentStack=None ) :
251  if currentStack is None : currentStack=[]
252  try :
253  duplicateIndex=currentStack.index( node ) # If there isn't a recursive loop this will raise a ValueError
254  if verbose :
255  print("Removing recursive loop in:")
256  for index in range(duplicateIndex,len(currentStack)) :
257  print(" ",currentStack[index].name,"-->")
258  print(" ",node.name)
259  currentStack[-1].dependencies.remove(node)
260  except ValueError:
261  # No recursive loop found, so continue traversing the tree
262  currentStack.append( node )
263  for subnode in node.dependencies :
264  removeRecursiveLoops( subnode, verbose, currentStack[:] )
const uint16_t range(const Frame &aFrame)
def removeRecursiveLoops
Definition: TreeCrawler.py:249
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def TreeCrawler.transformIntoGraph (   depgraph,
  toplevel 
)

Definition at line 265 of file TreeCrawler.py.

References removeRecursiveLoops().

Referenced by getImportTree().

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

Variable Documentation

list TreeCrawler._stack = []

Definition at line 47 of file TreeCrawler.py.