summaryrefslogtreecommitdiff
path: root/gr-howto-write-a-block/limbo/doc/make_numbered_listing.py
diff options
context:
space:
mode:
authorJohnathan Corgan2009-11-03 14:24:43 -0800
committerJohnathan Corgan2009-11-03 14:24:43 -0800
commit0bde79ebad973abdcfa23b4d50261fcee39cc28e (patch)
tree1bcc8ed9a899688afe3afdc93e9bcca87a7047b1 /gr-howto-write-a-block/limbo/doc/make_numbered_listing.py
parent3e366411a75b47eff5f76c76beb1f3a47006f6c7 (diff)
parent26d9beb0b51945915798e75ab24051adaa46d083 (diff)
downloadgnuradio-0bde79ebad973abdcfa23b4d50261fcee39cc28e.tar.gz
gnuradio-0bde79ebad973abdcfa23b4d50261fcee39cc28e.tar.bz2
gnuradio-0bde79ebad973abdcfa23b4d50261fcee39cc28e.zip
Merge branch 'wip/howto' of git@gnuradio.org:jcorgan
* 'wip/howto' of git@gnuradio.org:jcorgan: howto: moved osbsolete docs directory into limbo howto: make swig directory use individual .i files howto: reorganized directory structure howto: implement dynamic versioning howto: update m4 files to match latest master howto: updated INSTALL, fixed mode of config.*
Diffstat (limited to 'gr-howto-write-a-block/limbo/doc/make_numbered_listing.py')
-rwxr-xr-xgr-howto-write-a-block/limbo/doc/make_numbered_listing.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/gr-howto-write-a-block/limbo/doc/make_numbered_listing.py b/gr-howto-write-a-block/limbo/doc/make_numbered_listing.py
new file mode 100755
index 000000000..889c2d78d
--- /dev/null
+++ b/gr-howto-write-a-block/limbo/doc/make_numbered_listing.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+import sys
+import os, os.path
+from optparse import OptionParser
+
+def quote_line (line):
+ line = line.replace ('&', '&')
+ line = line.replace ('<', '&lt;')
+ line = line.replace ('>', '&gt;')
+ line = line.replace ("'", '&apos;')
+ line = line.replace ('"', '&quot;')
+ return line
+
+def generate_listing (input_filename, title=None):
+ inf = open (input_filename, "r")
+ output_filename = os.path.basename (input_filename) + '.xml'
+ outf = open (output_filename, "w")
+ outf.write ('<?xml version="1.0" encoding="ISO-8859-1"?>\n')
+ # outf.write ('<example id="%s">\n' % (input_filename,))
+ # if not title:
+ # title = input_filename
+ # outf.write ('<title>')
+ # outf.write (title)
+ # outf.write ('</title>\n')
+ outf.write ('<programlisting>\n');
+
+ lineno = 0
+ for line in inf:
+ line = line.expandtabs (8)
+ line = quote_line (line)
+ lineno = lineno + 1
+ outf.write ('%3d %s' % (lineno, line))
+
+ outf.write ('</programlisting>\n')
+ # outf.write ('</example>\n')
+
+
+def main ():
+ for file in sys.argv[1:]:
+ generate_listing (file)
+
+if __name__ == '__main__':
+ main ()
+