1 # usage: genmetaindex.py <xml-files> > index.xml
3 from xml.etree.ElementTree import ElementTree, Element
5 root = Element("index")
7 for file in sys.argv[1:]:
11 package = Element("package")
12 package.set("details", os.path.basename(file))
14 # we need all prerequisites
15 package.append(p.find("prerequisites"))
18 # we need some of the info, but not all
19 for i in p.findall("info"):
25 if i.tag not in ["name", "packagename", "packagetype", "shortdescription"]:
29 package.set(i.tag, i.text)
33 def indent(elem, level=0):
36 if not elem.text or not elem.text.strip():
38 if not elem.tail or not elem.tail.strip():
42 if not elem.tail or not elem.tail.strip():
45 if level and (not elem.tail or not elem.tail.strip()):
50 ElementTree(root).write(sys.stdout)