Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:18

0001 #! /usr/bin/env python3
0002 
0003 import sys
0004 import xml.etree.ElementTree as ET
0005 
0006 inputFile = sys.argv[1]
0007 print ("Reading input file ", inputFile)
0008 
0009 tree = ET.parse(inputFile)
0010 root = tree.getroot()
0011 
0012 sortList = []
0013 elem = root.find('MaterialSection')
0014 for subelem in elem :
0015      key = subelem.get('name')
0016      print (key)
0017      sortList.append((key, subelem))
0018 
0019 sortList.sort()
0020 for item in sortList :
0021   print (item[0])
0022 
0023 elem[:] = [item[-1] for item in sortList]
0024 
0025 outputFile = sys.argv[2]
0026 tree.write(outputFile)