2 # vi:si:et:sw=4:sts=4:ts=4
5 use the output from gst-xmlinspect.py to mangle tmpl/*.sgml and
6 insert/overwrite Short Description and Long Description
16 def __init__(self, filename):
17 self.filename = filename
23 Read and parse the sections from the given file.
25 lines = open(self.filename).readlines()
26 matcher = re.compile("<!-- ##### SECTION (\S+) ##### -->\n")
30 match = matcher.search(line)
32 id = match.expand("\\1")
33 self._sectionids.append(id)
34 self._sections[id] = []
38 "WARNING: line before a SECTION header: %s" % line)
40 self._sections[id].append(line)
42 def get_section(self, id):
44 Get the content from the given section.
46 return self._sections[id]
48 def set_section(self, id, content):
50 Replace the given section id with the given content.
52 self._sections[id] = content
56 Return the output of the current template in the tmpl/*.sgml format.
59 for id in self._sectionids:
60 lines.append("<!-- ##### SECTION %s ##### -->\n" % id)
61 for line in self._sections[id]:
68 Write out the template file again, backing up the previous one.
70 target = self.filename + ".mangle.bak"
71 os.rename(self.filename, target)
72 handle = open(self.filename, "w")
73 handle.write(self.output())
78 if len(sys.argv) > 1 and sys.argv[1]:
82 all = gst.registry_pool_plugin_list()
84 for feature in plugin.get_feature_list():
85 if isinstance(feature, gst.ElementFactory):
86 elements[feature.get_name()] = feature
88 for file in glob.glob("element-*.sgml"):
89 base = os.path.basename(file)
90 element = base[len("element-"):-len(".sgml")]
93 if element in elements.keys():
94 feature = elements[element]
95 description = feature.get_description()
96 tmpl.set_section("Short_Description", "%s\n\n" % description)
98 # put in an include if not yet there
99 line = '<include xmlns="http://www.w3.org/2003/XInclude" href="' + \
100 'element-' + element + '-details.xml" />\n'
101 section = tmpl.get_section("Long_Description")
102 if not section[0] == line:
103 section.insert(0, line)
104 tmpl.set_section("Long_Description", section)