10 parser = argparse.ArgumentParser(description=
'Take card file, blank all INFI directives and insert the INFI directives from the modifier file instead.',
12 formatter_class=argparse.RawDescriptionHelpFormatter)
14 parser.add_argument(
'inCfg', action=
'store',
15 help=
'name of the config-template')
16 parser.add_argument(
'modCfg', action=
'store',
17 help=
'name of the modifier file from mps_split')
18 parser.add_argument(
'outCfg', action=
'store',
19 help=
'name of modified output file')
20 parser.add_argument(
'isn', action=
'store',
21 help=
'number of the job (three digit number with leading zeros)')
22 parser.add_argument(
"--max-events", dest =
"max_events", type = int,
23 help =
"maximum number of events to process")
24 parser.add_argument(
"--skip-events", dest =
"skip_events", type = int,
25 help =
"number of events to skip before processing")
28 args = parser.parse_args()
36 with open(inCfg,
'r') as INFILE: 40 with open(modCfg,
'r') as MODFILE: 45 fileNames = mods.split(
'\n')
46 if 'CastorPool=' in fileNames[0]:
50 body = re.sub(re.compile(
'ISN',re.M), isn, body)
53 with open(outCfg,
'w')
as OUTFILE:
57 numberOfFiles = len(fileNames)
58 numberOfExtends =
int(math.ceil(numberOfFiles/255.))
61 for j
in xrange(numberOfExtends):
62 insertBlock =
"readFiles.extend([\n " 65 while (i<255)
and ((currentStart+i)<numberOfFiles):
66 entry = fileNames[currentStart+i].
strip()
67 if (i==254)
or ((currentStart+i+1)==numberOfFiles):
68 insertBlock +=
"\'"+entry+
"\'])\n" 70 insertBlock +=
"\'"+entry+
"\',\n " 73 for line
in fileinput.input(outCfg, inplace=1):
75 if re.match(
'readFiles\s*=\s*cms.untracked.vstring()',line):
78 if args.skip_events
is not None:
79 with open(outCfg,
"a")
as f:
80 f.write(
"process.source.skipEvents = cms.untracked.uint32({0:d})\n" 83 if args.max_events
is not None:
84 with open(outCfg,
"a")
as f:
85 f.write(
"process.maxEvents = cms.untracked.PSet(input = " 86 "cms.untracked.int32({0:d}))\n".
format(args.max_events))