3 from FWCore.PythonUtilities.XML2Python
import xml2obj
4 from FWCore.PythonUtilities.LumiList
import LumiList
5 from pprint
import pprint
12 if __name__ ==
'__main__':
14 parser = optparse.OptionParser (
"Usage: %prog [--options] job1.fjr [job2.fjr...]")
15 parser.add_option (
'--output', dest=
'output', type=
'string',
16 help=
'Save output to file OUTPUT')
17 (options, args) = parser.parse_args()
19 raise RuntimeError(
"Must provide at least one input file")
24 obj = xml2obj (filename=fjr)
26 print "'%s' is not an framework job report. Skipping." % fjr
28 for inputFile
in obj.InputFile:
30 runObjects = inputFile.Runs.Run
31 for run
in runObjects:
32 runNumber = int (run.ID)
33 runList = runsLumisDict.setdefault (runNumber, [])
34 for lumiPiece
in run.LumiSection:
35 lumi = int (lumiPiece.ID)
39 if isinstance(inputFile.Runs, basestring):
40 runObjects = [inputFile.Runs]
42 runObjects = inputFile.Runs
44 for runObject
in runObjects:
46 runs = ast.literal_eval(runObject)
47 for (run, lumis)
in runs.iteritems():
48 runList = runsLumisDict.setdefault (int(run), [])
53 print "Run missing in '%s'. Skipping." % fjr
56 jsonList = LumiList (runsAndLumis = runsLumisDict)
58 jsonList.writeJSON (options.output)