1 # usage: genmetaindex.py <language> <xml-files> > index.xml
3 from xml.etree.ElementTree import ElementTree, Element
7 root = Element("index")
9 for file in sys.argv[2:]:
13 package = Element("package")
14 package.set("details", os.path.basename(file))
16 # we need all prerequisuited
17 package.append(p.find("prerequisites"))
20 # we need some of the info, but only our locale
21 for i in p.findall("info"):
22 if not info or i.get("language") == language:
27 if i.tag not in ["name", "packagename", "shortdescription"]:
31 package.set(i.tag, i.text)
35 def indent(elem, level=0):
38 if not elem.text or not elem.text.strip():
40 if not elem.tail or not elem.tail.strip():
44 if not elem.tail or not elem.tail.strip():
47 if level and (not elem.tail or not elem.tail.strip()):
52 ElementTree(root).write(sys.stdout)