summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1998-11-23 15:14:18 (GMT)
committerFred Drake <fdrake@acm.org>1998-11-23 15:14:18 (GMT)
commitc16149b17b3b13226a045d97be760dbf71be3fd9 (patch)
tree23991b6db15f0c5e7934823109a1520746e88148 /Doc/tools
parent96b07a9453cea31e40ee00a69838d4fc29ad3d66 (diff)
downloadcpython-c16149b17b3b13226a045d97be760dbf71be3fd9.zip
cpython-c16149b17b3b13226a045d97be760dbf71be3fd9.tar.gz
cpython-c16149b17b3b13226a045d97be760dbf71be3fd9.tar.bz2
Some cleanup.
Don't duplicate the information on what's empty; rely on the input data for that. (This means that the DOM may need more work.)
Diffstat (limited to 'Doc/tools')
-rwxr-xr-xDoc/tools/esis2sgml.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/Doc/tools/esis2sgml.py b/Doc/tools/esis2sgml.py
index 442d408..5f8c6e8 100755
--- a/Doc/tools/esis2sgml.py
+++ b/Doc/tools/esis2sgml.py
@@ -1,10 +1,13 @@
#! /usr/bin/env python
-"""
+"""Convert ESIS events to SGML or XML markup.
+
+This is limited, but seems sufficient for the ESIS generated by the
+latex2esis.py script when run over the Python documentation.
"""
__version__ = '$Revision$'
-
+import errno
import re
import string
@@ -64,6 +67,9 @@ def do_convert(ifp, ofp, knownempties, xml=0):
ofp.write("<%s%s/>" % (data, format_attrs(attrs)))
else:
ofp.write("<%s%s>" % (data, format_attrs(attrs)))
+ if knownempty and data not in knownempties:
+ # accumulate knowledge!
+ knownempties.append(data)
attrs = {}
lastopened = data
lastempty = knownempty
@@ -87,11 +93,11 @@ def do_convert(ifp, ofp, knownempties, xml=0):
def sgml_convert(ifp, ofp, knownempties=()):
- return do_convert(ifp, ofp, knownempties, xml=0)
+ return do_convert(ifp, ofp, list(knownempties), xml=0)
-def xml_convert(ifp, ofp, knownempties=[]):
- return do_convert(ifp, ofp, knownempties, xml=1)
+def xml_convert(ifp, ofp, knownempties=()):
+ return do_convert(ifp, ofp, list(knownempties), xml=1)
def main():
@@ -114,11 +120,11 @@ def main():
usage()
sys.exit(2)
# knownempties is ignored in the XML version
- convert(ifp, ofp, knownempties=["rfc", "POSIX", "ASCII", "declaremodule",
- "maketitle", "makeindex", "makemodindex",
- "localmoduletable", "ABC", "UNIX", "Cpp",
- "C", "EOF", "NULL", "manpage", "input",
- "label"])
+ try:
+ convert(ifp, ofp)
+ except IOError, (err, msg):
+ if err != errno.EPIPE:
+ raise
if __name__ == "__main__":