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
19 def __init__(self, filename):
20 self.filename = filename
26 Read and parse the sections from the given file.
28 lines = open(self.filename).readlines()
29 matcher = re.compile("<!-- ##### SECTION (\S+) ##### -->\n")
33 match = matcher.search(line)
35 id = match.expand("\\1")
36 self._sectionids.append(id)
37 self._sections[id] = []
41 "WARNING: line before a SECTION header: %s" % line)
43 self._sections[id].append(line)
45 def get_section(self, id):
47 Get the content from the given section.
49 return self._sections[id]
51 def set_section(self, id, content):
53 Replace the given section id with the given content.
55 self._sections[id] = content
59 Return the output of the current template in the tmpl/*.sgml format.
62 for id in self._sectionids:
63 lines.append("<!-- ##### SECTION %s ##### -->\n" % id)
64 for line in self._sections[id]:
71 Write out the template file again, backing up the previous one.
73 target = self.filename + ".mangle.bak"
74 os.rename(self.filename, target)
75 handle = open(self.filename, "w")
76 handle.write(self.output())
81 if len(sys.argv) > 1 and sys.argv[1]:
85 all = gst.registry_pool_plugin_list()
87 for feature in plugin.get_feature_list():
88 if isinstance(feature, gst.ElementFactory):
89 elements[feature.get_name()] = feature
91 for file in glob.glob("element-*.sgml"):
92 base = os.path.basename(file)
93 element = base[len("element-"):-len(".sgml")]
96 if element in elements.keys():
97 feature = elements[element]
98 description = feature.get_description()
99 tmpl.set_section("Short_Description", "%s\n\n" % description)
101 # put in an include if not yet there
102 line = '<include xmlns="http://www.w3.org/2003/XInclude" href="' + \
103 'element-' + element + '-details.xml" />\n'
104 section = tmpl.get_section("Long_Description")
105 if not section[0] == line:
106 section.insert(0, line)
107 tmpl.set_section("Long_Description", section)