5 if(os.path.exists(outputFile)):
6 print (
"outputFile ",outputFile,
" already exists. Will rename to ",outputFile,
".OLD")
7 os.rename(outputFile,outputFile+
".OLD")
8 output =
open(outputFile,
'w')
11 for file
in listOfFiles:
12 cmd =
"grep /event "+file+
" | wc -l"
13 nevents+=
int(subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=
True))
15 for file
in listOfFiles:
18 print (
"*** Starting file ",file)
19 for line
in open(file,
"r"):
25 if(
"<event" in line
and inHeader):
27 if(len(holdHeader)<1):
33 elif(
not inHeader
and not (
"</LesHouchesEvents>" in line)):
37 if(
"nevents" in line
and "Required accuracy" not in line):
40 line = line.replace(tmp[0],
str(nevents))
41 elif(
"numevts" in line):
45 line = line.replace(tmp[1],nnn)
47 output.write(
"</LesHouchesEvents>\n")