1 import xml
.etree
.ElementTree
as ET
4 tree
= ET
.parse(sys
.argv
[1])
5 # the xml tree is of the form
6 # <expr><list> {all options, each an attrs} </list></expr>
7 options
= list(tree
.getroot().find('list'))
11 if s
.startswith("enable"):
13 if s
.startswith("package"):
18 (order(p
.attrib
['value']), p
.attrib
['value'])
19 for p
in opt
.findall('attr[@name="loc"]/list/string')
22 options
.sort(key
=sortKey
)
24 doc
= ET
.Element("expr")
25 newOptions
= ET
.SubElement(doc
, "list")
26 newOptions
.extend(options
)
27 ET
.ElementTree(doc
).write(sys
.argv
[2], encoding
='utf-8')