File: docbook.py

package info (click to toggle)
zope-devguide 20011206-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 456 kB
  • ctags: 45
  • sloc: python: 152; makefile: 124; sh: 54
file content (23 lines) | stat: -rw-r--r-- 623 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/python
import sys
import os.path
from StructuredText import DocBookChapterWithFigures, DocumentWithImages, Basic

if not sys.argv[1:]:
    print """
Usage: docbook.py <file.stx>...

Converts one or more structured text (.stx) files to docbook xml
(.xml) files.
"""

for filename in sys.argv[1:]:
    xmlfile="%s.xml" % os.path.splitext(filename)[0]
    print "%s -> %s" % (filename, xmlfile)
    f=open(xmlfile, "wb")
    f.write('<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook V4.1//EN">\n')
    f.write(DocBookChapterWithFigures(DocumentWithImages(Basic(open(filename).read()))))
    f.close()