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 set_section(self, id, content):
44 Replace the given section id with the given content.
46 self._sections[id] = content
50 Return the output of the current template in the tmpl/*.sgml format.
53 for id in self._sectionids:
54 lines.append("<!-- ##### SECTION %s ##### -->\n" % id)
55 for line in self._sections[id]:
62 Write out the template file again, backing up the previous one.
64 target = self.filename + ".mangle.bak"
65 os.rename(self.filename, target)
66 handle = open(self.filename, "w")
67 handle.write(self.output())
72 if len(sys.argv) > 1 and sys.argv[1]:
76 all = gst.registry_pool_plugin_list()
78 for feature in plugin.get_feature_list():
79 if isinstance(feature, gst.ElementFactory):
80 elements[feature.get_name()] = feature
82 for file in glob.glob("element-*.sgml"):
83 base = os.path.basename(file)
84 element = base[len("element-"):-len(".sgml")]
87 if element in elements.keys():
88 feature = elements[element]
89 description = feature.get_description()
90 tmpl.set_section("Short_Description", "%s\n\n" % description)
91 tmpl.set_section("Long_Description",
92 '<include xmlns="http://www.w3.org/2003/XInclude" href="element-' +
93 element + '-details.xml" />\n<para>\n\n</para>\n')