2 from __future__
import print_function
11 parser = argparse.ArgumentParser(description=
'Take card file, blank all INFI directives and insert the INFI directives from the modifier file instead.',
13 formatter_class=argparse.RawDescriptionHelpFormatter)
15 parser.add_argument(
'inCfg', action=
'store',
16 help=
'name of the config-template')
17 parser.add_argument(
'modCfg', action=
'store',
18 help=
'name of the modifier file from mps_split')
19 parser.add_argument(
'outCfg', action=
'store',
20 help=
'name of modified output file')
21 parser.add_argument(
'isn', action=
'store',
22 help=
'number of the job (three digit number with leading zeros)')
23 parser.add_argument(
"--max-events", dest =
"max_events", type = int,
24 help =
"maximum number of events to process")
25 parser.add_argument(
"--skip-events", dest =
"skip_events", type = int,
26 help =
"number of events to skip before processing")
29 args = parser.parse_args()
37 with open(inCfg,
'r') as INFILE: 41 with open(modCfg,
'r') as MODFILE: 46 fileNames = mods.split(
'\n')
47 if 'CastorPool=' in fileNames[0]:
51 body = re.sub(re.compile(
'ISN',re.M), isn, body)
54 with open(outCfg,
'w')
as OUTFILE:
58 numberOfFiles = len(fileNames)
59 numberOfExtends =
int(math.ceil(numberOfFiles/255.))
62 for j
in xrange(numberOfExtends):
63 insertBlock =
"readFiles.extend([\n " 66 while (i<255)
and ((currentStart+i)<numberOfFiles):
67 entry = fileNames[currentStart+i].
strip()
68 if (i==254)
or ((currentStart+i+1)==numberOfFiles):
69 insertBlock +=
"\'"+entry+
"\'])\n" 71 insertBlock +=
"\'"+entry+
"\',\n " 74 for line
in fileinput.input(outCfg, inplace=1):
76 if re.match(
'readFiles\s*=\s*cms.untracked.vstring()',line):
77 print(insertBlock,end=
'')
79 if args.skip_events
is not None:
80 with open(outCfg,
"a")
as f:
81 f.write(
"process.source.skipEvents = cms.untracked.uint32({0:d})\n" 84 if args.max_events
is not None:
85 with open(outCfg,
"a")
as f:
86 f.write(
"process.maxEvents = cms.untracked.PSet(input = " 87 "cms.untracked.int32({0:d}))\n".
format(args.max_events))
S & print(S &os, JobReport::InputFile const &f)