docs: further reduce delta to upstream makefiles
[platform/upstream/gst-common.git] / c-to-xml.py
1 # -*- Mode: Python -*-
2 # vi:si:et:sw=4:sts=4:ts=4
3
4 """
5 Convert a C program to valid XML to be included in docbook
6 """
7
8 import sys
9 import os
10 from xml.sax import saxutils
11
12 def main():
13     if len(sys.argv) == 1:
14         sys.stderr.write("Please specify a source file to convert")
15         sys.exit(1)
16     source = sys.argv[1]
17
18     if not os.path.exists(source):
19         sys.stderr.write("%s does not exist.\n" % source)
20         sys.exit(1)
21
22     content = open(source, "r").read()
23
24     # print header
25     print '<?xml version="1.0"?>'
26     print '<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">'
27     print
28     print '<programlisting>'
29
30     # print content
31     print saxutils.escape(content).encode('UTF-8')
32     print '</programlisting>'
33
34 main()