Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:23

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