Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:44

0001 import subprocess
0002 from __future__ import print_function
0003 
0004 infile   = open("alignment_export_2018_12_07.1.xml","rt")
0005 xmllines = infile.readlines()
0006 infile.close()
0007 #tree = ET.parse(infilename)
0008 #root = tree.getroot()
0009 outfile =open("test.xml","wt")
0010 iov = 0
0011 
0012 firstline = xmllines.pop(0)
0013 secondline = xmllines.pop(0)
0014 lastline = xmllines.pop(-1)
0015 
0016 for line in xmllines:
0017     if "iov" not in line:
0018         outfile.write(line)
0019     else:
0020         if "</iov>" in line:
0021             outfile.write(line)
0022             outfile.write(lastline)
0023             outfile.close()
0024             outfilename = "real_alignment_iov"+str(iov)+".xml"
0025             output = subprocess.run("mv test.xml "+outfilename, shell=True, check=True)
0026             outfile=open("test.xml","wt")
0027         else:
0028             outfile.write(firstline)
0029             outfile.write(secondline)
0030             outfile.write(line)
0031             iovfirstfield = line.split()[1].split("=\"")[1].split(":")[0]
0032             iov = int(iovfirstfield)
0033             print (iov)
0034 
0035 if not  outfile.closed:
0036     outfile.close()