import FWCore.ParameterSet.Config as cms import FWCore.ParameterSet.parseConfig as cmsParse from sys import argv fileInPath = argv[1] if fileInPath.endswith('cfg'): print cmsParse.dumpCfg(fileInPath) else: print cmsParse.dumpCff(fileInPath)
overwrite = True if argv[len(argv)-1] == 'no_overwrite': overwrite = False for fileName in files: if fileName.endswith('cfg'): newName = cfgName2py.cfgName2py(fileName) if os.path.exists(newName) and not overwrite: continue newPath = os.path.dirname(newName) if newPath != '' and not os.path.exists(newPath): os.makedirs(newPath) f = open(newName, 'w') try: f.write(cmsParse.dumpCfg(fileName)) except: print "ERROR in "+fileName f.close() os.remove(newName) else: f.close() else: print fileName includeNode = cmsParse._IncludeNode(fileName) try: includeNode.createFile(overwrite) except: # keep going print "ERROR in "+fileName os.remove(includeNode.pythonFileName())