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.)
This commit is contained in:
Fred Drake 1998-11-23 15:14:18 +00:00
parent 96b07a9453
commit c16149b17b
1 changed files with 16 additions and 10 deletions

View File

@ -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__":