[MerlinEPGCenter] removed reference to nonexistent (and not required) progress pixmap
[enigma2-plugins.git] / genmetaindex.py
1 # usage: genmetaindex.py <xml-files>  > index.xml
2 import sys, os
3 from xml.etree.ElementTree import ElementTree, Element
4
5 root = Element("index")
6
7 for file in sys.argv[1:]:
8         p = ElementTree()
9         p.parse(file)
10         
11         package = Element("package")
12         package.set("details", os.path.basename(file))
13         
14         # we need all prerequisites
15         prerequisites = p.find("prerequisites")
16         if prerequisites is None:
17                 continue
18         package.append(prerequisites)
19         
20         # we need some of the info, but not all
21         info = p.find("info")
22         if info is None:
23                 continue
24         
25         for i in info:
26                 if i.tag in ("name", "packagename", "packagetype", "shortdescription"):
27                         package.set(i.tag, i.text)
28
29         root.append(package)
30
31 def indent(elem, level=0):
32         i = "\n" + level*"\t"
33         if elem != None and len(elem):
34                 if not elem.text or not elem.text.strip():
35                         elem.text = i + "\t"
36                 if not elem.tail or not elem.tail.strip():
37                         elem.tail = i
38                 for elem in elem:
39                         indent(elem, level+1)
40                 if not elem.tail or not elem.tail.strip():
41                         elem.tail = i
42         else:
43                 if level and (not elem.tail or not elem.tail.strip()):
44                         elem.tail = i
45
46 indent(root)
47
48 ElementTree(root).write(sys.stdout)