Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /FWCore/ParameterSet/scripts/edmPythonSearch is written in an unsupported language. File is not indexed.

0001 #! /usr/bin/env python3
0002 
0003 from FWCore.ParameterSet.TreeCrawler import getImportTree, Color
0004 import sys, os
0005 from argparse import ArgumentParser
0006 parser = ArgumentParser()
0007 parser.add_argument("searchString",type=str)
0008 parser.add_argument("configFile",type=str)
0009 options = parser.parse_args()
0010 
0011 sys.path.append(os.environ["PWD"])
0012 path = sys.path[:]
0013 
0014 # get the import tree
0015 importTree = getImportTree(options.configFile, path)
0016 
0017 # search the tree
0018 result = []
0019 importTree.search(options.searchString,result)
0020 
0021 # sort the output by file name
0022 result.sort(key= lambda x: x.options.configFile)
0023 dumpStack = True
0024 # dump to screen
0025 for item in result:
0026     print(item.line.replace(options.searchString,Color.hilight+options.searchString+Color.none))
0027     print("%s (line: %s)"  %(item.filename, item.number))
0028     if dumpStack and hasattr(item, 'stacks'):
0029        # make a set of strings, so it's unique
0030        froms = set()
0031        for stack in item.stacks:
0032           froms.add('From ' + ' -> '.join(stack))
0033        print('\n'.join(froms))
0034     print('\n')