diff options
author | Fred Drake <fdrake@acm.org> | 1999-07-29 22:03:52 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1999-07-29 22:03:52 (GMT) |
commit | f032cdbb2447a723e65ae76dad554e6c82032e4a (patch) | |
tree | b1a69b37b90774e9b20c77c1f4af6a6111b3204a | |
parent | bc2285eb60e5467cc6be41f6877b9d609b140de9 (diff) | |
download | cpython-f032cdbb2447a723e65ae76dad554e6c82032e4a.zip cpython-f032cdbb2447a723e65ae76dad554e6c82032e4a.tar.gz cpython-f032cdbb2447a723e65ae76dad554e6c82032e4a.tar.bz2 |
Some minor cleanup.
-rwxr-xr-x | Doc/tools/sgmlconv/esis2sgml.py | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/Doc/tools/sgmlconv/esis2sgml.py b/Doc/tools/sgmlconv/esis2sgml.py index aabbe71..38866ce 100755 --- a/Doc/tools/sgmlconv/esis2sgml.py +++ b/Doc/tools/sgmlconv/esis2sgml.py @@ -77,7 +77,7 @@ def istoken(s): return _token_rx.match(s) is not None -def do_convert(ifp, ofp, xml=0, autoclose=(), verbatims=()): +def convert(ifp, ofp, xml=0, autoclose=(), verbatims=()): if xml: autoclose = () attrs = {} @@ -152,26 +152,27 @@ def do_convert(ifp, ofp, xml=0, autoclose=(), verbatims=()): def dump_empty_element_names(knownempties): + d = {} + for gi in knownempties: + d[gi] = gi knownempties.append("") if os.path.isfile(EMPTIES_FILENAME): - mode = "a" - else: - mode = "w" - fp = open(EMPTIES_FILENAME, mode) - fp.write(string.join(knownempties, "\n")) + fp = open(EMPTIES_FILENAME) + while 1: + line = fp.readline() + if not line: + break + gi = string.strip(line) + if gi: + d[gi] = gi + fp = open(EMPTIES_FILENAME, "w") + gilist = d.keys() + gilist.sort() + fp.write(string.join(gilist, "\n")) + fp.write("\n") fp.close() -def sgml_convert(ifp, ofp, autoclose, verbatims): - return do_convert(ifp, ofp, xml=0, - autoclose=autoclose, verbatims=verbatims) - - -def xml_convert(ifp, ofp, autoclose, verbatims): - return do_convert(ifp, ofp, xml=1, - autoclose=autoclose, verbatims=verbatims) - - def update_gi_map(map, names, fromsgml=1): for name in string.split(names, ","): if fromsgml: @@ -186,7 +187,6 @@ def main(): import sys # autoclose = AUTOCLOSE - convert = xml_convert xml = 1 xmldecl = 0 elem_names = '' @@ -205,10 +205,8 @@ def main(): LIST_EMPTIES = 1 elif opt in ("-s", "--sgml"): xml = 0 - convert = sgml_convert elif opt in ("-x", "--xml"): xml = 1 - convert = xml_convert elif opt in ("-a", "--autoclose"): autoclose = string.split(arg, ",") elif opt == "--elements-map": @@ -252,7 +250,7 @@ def main(): try: if xml and xmldecl: opf.write('<?xml version="1.0" encoding="iso8859-1"?>\n') - convert(ifp, ofp, autoclose, verbatims) + convert(ifp, ofp, xml=xml, autoclose=autoclose, verbatims=verbatims) except IOError, (err, msg): if err != errno.EPIPE: raise |