3 from __future__
import print_function
4 from FWCore.PythonUtilities.XML2Python
import xml2obj
5 from FWCore.PythonUtilities.LumiList
import LumiList
6 from pprint
import pprint
14 if __name__ ==
'__main__':
16 parser = optparse.OptionParser (
"Usage: %prog [--options] job1.fjr [job2.fjr...]")
17 parser.add_option (
'--output', dest=
'output', type=
'string',
18 help=
'Save output to file OUTPUT')
19 (options, args) = parser.parse_args()
21 raise RuntimeError(
"Must provide at least one input file")
26 obj = xml2obj (filename=fjr)
28 print(
"'%s' is not an framework job report. Skipping." % fjr)
30 for inputFile
in obj.InputFile:
32 runObjects = inputFile.Runs.Run
33 for run
in runObjects:
34 runNumber = int (run.ID)
35 runList = runsLumisDict.setdefault (runNumber, [])
36 for lumiPiece
in run.LumiSection:
37 lumi = int (lumiPiece.ID)
41 if isinstance(inputFile.Runs, str):
42 runObjects = [inputFile.Runs]
44 runObjects = inputFile.Runs
46 for runObject
in runObjects:
48 runs = ast.literal_eval(runObject)
49 for (run, lumis)
in six.iteritems(runs):
50 runList = runsLumisDict.setdefault (
int(run), [])
55 print(
"Run missing in '%s'. Skipping." % fjr)
58 jsonList = LumiList (runsAndLumis = runsLumisDict)
60 jsonList.writeJSON (options.output)
S & print(S &os, JobReport::InputFile const &f)