3 from FWCore.PythonUtilities.XML2Python
import xml2obj
4 from FWCore.PythonUtilities.LumiList
import LumiList
5 from pprint
import pprint
10 if __name__ ==
'__main__':
12 parser = optparse.OptionParser (
"Usage: %prog [--options] job1.fjr [job2.fjr...]")
13 parser.add_option (
'--output', dest=
'output', type=
'string',
14 help=
'Save output to file OUTPUT')
15 (options, args) = parser.parse_args()
17 raise RuntimeError,
"Must provide at least one input file"
22 obj = xml2obj (filename=fjr)
24 print "'%s' is not an framework job report. Skipping." % fjr
26 for inputFile
in obj.InputFile:
28 runList = inputFile.Runs.Run
31 print "'%s' in '%s' contains no runs. Skipping." % \
34 print "Some run in '%s' contains no runs. Skipping." % \
38 runNumber = int (run.ID)
39 runList = runsLumisDict.setdefault (runNumber, [])
40 for lumiPiece
in run.LumiSection:
41 lumi = int (lumiPiece.ID)
44 jsonList = LumiList (runsAndLumis = runsLumisDict)
46 jsonList.writeJSON (options.output)