Remove bogus stdout redirection and use of sys.__stdout__; use

augmented print statement instead.
This commit is contained in:
Fred Drake 2000-10-26 03:56:46 +00:00
parent 33e2c3ece3
commit 9c6850510c
1 changed files with 42 additions and 46 deletions

View File

@ -91,56 +91,54 @@ def maketables():
FILE = "Modules/unicodedata_db.h"
sys.stdout = open(FILE, "w")
print "/* this file was generated by %s %s */" % (SCRIPT, VERSION)
print
print "/* a list of unique database records */"
print "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {"
fp = open(FILE, "w")
print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION)
print >>fp
print >>fp, "/* a list of unique database records */"
print >>fp, \
"const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {"
for item in table:
print " {%d, %d, %d, %d}," % item
print "};"
print
print >>fp, " {%d, %d, %d, %d}," % item
print >>fp, "};"
print >>fp
# FIXME: the following tables should be made static, and
# the support code moved into unicodedatabase.c
print "/* string literals */"
print "const char *_PyUnicode_CategoryNames[] = {"
print >>fp, "/* string literals */"
print >>fp, "const char *_PyUnicode_CategoryNames[] = {"
for name in CATEGORY_NAMES:
print " \"%s\"," % name
print " NULL"
print "};"
print >>fp, " \"%s\"," % name
print >>fp, " NULL"
print >>fp, "};"
print "const char *_PyUnicode_BidirectionalNames[] = {"
print >>fp, "const char *_PyUnicode_BidirectionalNames[] = {"
for name in BIDIRECTIONAL_NAMES:
print " \"%s\"," % name
print " NULL"
print "};"
print >>fp, " \"%s\"," % name
print >>fp, " NULL"
print >>fp, "};"
print "static const char *decomp_data[] = {"
print >>fp, "static const char *decomp_data[] = {"
for name in decomp_data:
print " \"%s\"," % name
print " NULL"
print "};"
print >>fp, " \"%s\"," % name
print >>fp, " NULL"
print >>fp, "};"
# split record index table
index1, index2, shift = splitbins(index)
print "/* index tables for the database records */"
print "#define SHIFT", shift
Array("index1", index1).dump(sys.stdout)
Array("index2", index2).dump(sys.stdout)
print >>fp, "/* index tables for the database records */"
print >>fp, "#define SHIFT", shift
Array("index1", index1).dump(fp)
Array("index2", index2).dump(fp)
# split decomposition index table
index1, index2, shift = splitbins(decomp_index)
print "/* index tables for the decomposition data */"
print "#define DECOMP_SHIFT", shift
Array("decomp_index1", index1).dump(sys.stdout)
Array("decomp_index2", index2).dump(sys.stdout)
sys.stdout = sys.__stdout__
print >>fp, "/* index tables for the decomposition data */"
print >>fp, "#define DECOMP_SHIFT", shift
Array("decomp_index1", index1).dump(fp)
Array("decomp_index2", index2).dump(fp)
#
# 3) unicode type data
@ -206,26 +204,24 @@ def maketables():
FILE = "Objects/unicodetype_db.h"
sys.stdout = open(FILE, "w")
fp = open(FILE, "w")
print "/* this file was generated by %s %s */" % (SCRIPT, VERSION)
print
print "/* a list of unique character type descriptors */"
print "const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = {"
print >>fp, "/* this file was generated by %s %s */" % (SCRIPT, VERSION)
print >>fp
print >>fp, "/* a list of unique character type descriptors */"
print >>fp, "const _PyUnicode_TypeRecord _PyUnicode_TypeRecords[] = {"
for item in table:
print " {%d, %d, %d, %d, %d, %d}," % item
print "};"
print
print >>fp, " {%d, %d, %d, %d, %d, %d}," % item
print >>fp, "};"
print >>fp
# split decomposition index table
index1, index2, shift = splitbins(index)
print "/* type indexes */"
print "#define SHIFT", shift
Array("index1", index1).dump(sys.stdout)
Array("index2", index2).dump(sys.stdout)
sys.stdout = sys.__stdout__
print >>fp, "/* type indexes */"
print >>fp, "#define SHIFT", shift
Array("index1", index1).dump(fp)
Array("index2", index2).dump(fp)
# --------------------------------------------------------------------
# the following support code is taken from the unidb utilities