mirror of https://github.com/python/cpython.git
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:
parent
96b07a9453
commit
c16149b17b
|
@ -1,10 +1,13 @@
|
||||||
#! /usr/bin/env python
|
#! /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$'
|
__version__ = '$Revision$'
|
||||||
|
|
||||||
|
import errno
|
||||||
import re
|
import re
|
||||||
import string
|
import string
|
||||||
|
|
||||||
|
@ -64,6 +67,9 @@ def do_convert(ifp, ofp, knownempties, xml=0):
|
||||||
ofp.write("<%s%s/>" % (data, format_attrs(attrs)))
|
ofp.write("<%s%s/>" % (data, format_attrs(attrs)))
|
||||||
else:
|
else:
|
||||||
ofp.write("<%s%s>" % (data, format_attrs(attrs)))
|
ofp.write("<%s%s>" % (data, format_attrs(attrs)))
|
||||||
|
if knownempty and data not in knownempties:
|
||||||
|
# accumulate knowledge!
|
||||||
|
knownempties.append(data)
|
||||||
attrs = {}
|
attrs = {}
|
||||||
lastopened = data
|
lastopened = data
|
||||||
lastempty = knownempty
|
lastempty = knownempty
|
||||||
|
@ -87,11 +93,11 @@ def do_convert(ifp, ofp, knownempties, xml=0):
|
||||||
|
|
||||||
|
|
||||||
def sgml_convert(ifp, ofp, knownempties=()):
|
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=[]):
|
def xml_convert(ifp, ofp, knownempties=()):
|
||||||
return do_convert(ifp, ofp, knownempties, xml=1)
|
return do_convert(ifp, ofp, list(knownempties), xml=1)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -114,11 +120,11 @@ def main():
|
||||||
usage()
|
usage()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
# knownempties is ignored in the XML version
|
# knownempties is ignored in the XML version
|
||||||
convert(ifp, ofp, knownempties=["rfc", "POSIX", "ASCII", "declaremodule",
|
try:
|
||||||
"maketitle", "makeindex", "makemodindex",
|
convert(ifp, ofp)
|
||||||
"localmoduletable", "ABC", "UNIX", "Cpp",
|
except IOError, (err, msg):
|
||||||
"C", "EOF", "NULL", "manpage", "input",
|
if err != errno.EPIPE:
|
||||||
"label"])
|
raise
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue