summaryrefslogtreecommitdiffstats
path: root/Tools/unicode/mkstringprep.py
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-08-03 17:06:41 (GMT)
committerCollin Winter <collinw@gmail.com>2007-08-03 17:06:41 (GMT)
commit6afaeb757af0dbd8508a0f2352ade61e41bec84c (patch)
treef1b31bc7138b17ff39791bbb45aa81583c3b6e46 /Tools/unicode/mkstringprep.py
parente5d0e8431f929cad2da77b63fe1b7dc0ff21a428 (diff)
downloadcpython-6afaeb757af0dbd8508a0f2352ade61e41bec84c.zip
cpython-6afaeb757af0dbd8508a0f2352ade61e41bec84c.tar.gz
cpython-6afaeb757af0dbd8508a0f2352ade61e41bec84c.tar.bz2
Convert print statements to function calls in Tools/.
Diffstat (limited to 'Tools/unicode/mkstringprep.py')
-rw-r--r--Tools/unicode/mkstringprep.py84
1 files changed, 42 insertions, 42 deletions
diff --git a/Tools/unicode/mkstringprep.py b/Tools/unicode/mkstringprep.py
index 5be44c9..b910d69 100644
--- a/Tools/unicode/mkstringprep.py
+++ b/Tools/unicode/mkstringprep.py
@@ -106,7 +106,7 @@ for l in data:
########### Generate compact Python versions of the tables #############
-print """# This file is generated by mkstringprep.py. DO NOT EDIT.
+print("""# This file is generated by mkstringprep.py. DO NOT EDIT.
\"\"\"Library that exposes various tables found in the StringPrep RFC 3454.
There are two kinds of tables: sets, for which a member test is provided,
@@ -114,9 +114,9 @@ and mappings, for which a mapping function is provided.
\"\"\"
import unicodedata
-"""
+""")
-print "assert unicodedata.unidata_version == %s" % repr(unicodedata.unidata_version)
+print("assert unicodedata.unidata_version == %s" % repr(unicodedata.unidata_version))
# A.1 is the table of unassigned characters
# XXX Plane 15 PUA is listed as unassigned in Python.
@@ -134,13 +134,13 @@ Cn -= set(range(0xFFFF, 0x110000, 0x10000))
# assert table == Cn
-print """
+print("""
def in_table_a1(code):
if unicodedata.category(code) != 'Cn': return False
c = ord(code)
if 0xFDD0 <= c < 0xFDF0: return False
return (c & 0xFFFF) not in (0xFFFE, 0xFFFF)
-"""
+""")
# B.1 cannot easily be derived
name, table = tables[0]
@@ -148,11 +148,11 @@ del tables[0]
assert name == "B.1"
table = table.keys()
table.sort()
-print """
+print("""
b1_set = """ + compact_set(table) + """
def in_table_b1(code):
return ord(code) in b1_set
-"""
+""")
# B.2 and B.3 is case folding.
# It takes CaseFolding.txt into account, which is
@@ -180,20 +180,20 @@ for k,v in table_b2.items():
b3 = b3_exceptions.items()
b3.sort()
-print """
-b3_exceptions = {"""
+print("""
+b3_exceptions = {""")
for i,(k,v) in enumerate(b3):
- print "0x%x:%s," % (k, repr(v)),
+ print("0x%x:%s," % (k, repr(v)), end=' ')
if i % 4 == 3:
- print
-print "}"
+ print()
+print("}")
-print """
+print("""
def map_table_b3(code):
r = b3_exceptions.get(ord(code))
if r is not None: return r
return code.lower()
-"""
+""")
def map_table_b3(code):
r = b3_exceptions.get(ord(code))
@@ -222,7 +222,7 @@ for k,v in table_b2.items():
# B.3 should not add any additional special cases
assert specials == {}
-print """
+print("""
def map_table_b2(a):
al = map_table_b3(a)
b = unicodedata.normalize("NFKC", al)
@@ -232,7 +232,7 @@ def map_table_b2(a):
return c
else:
return al
-"""
+""")
# C.1.1 is a table with a single character
name, table = tables[0]
@@ -240,10 +240,10 @@ del tables[0]
assert name == "C.1.1"
assert table == {0x20:0x20}
-print """
+print("""
def in_table_c11(code):
return code == u" "
-"""
+""")
# C.1.2 is the rest of all space characters
name, table = tables[0]
@@ -254,13 +254,13 @@ assert name == "C.1.2"
# Zs = set(gen_category(["Zs"])) - set([0x20])
# assert Zs == table
-print """
+print("""
def in_table_c12(code):
return unicodedata.category(code) == "Zs" and code != u" "
def in_table_c11_c12(code):
return unicodedata.category(code) == "Zs"
-"""
+""")
# C.2.1 ASCII control characters
name, table_c21 = tables[0]
@@ -272,10 +272,10 @@ Cc_ascii = Cc & set(range(128))
table_c21 = set(table_c21.keys())
assert Cc_ascii == table_c21
-print """
+print("""
def in_table_c21(code):
return ord(code) < 128 and unicodedata.category(code) == "Cc"
-"""
+""")
# C.2.2 Non-ASCII control characters. It also includes
# a number of characters in category Cf.
@@ -290,7 +290,7 @@ assert len(Cc_nonascii - table_c22) == 0
specials = list(table_c22 - Cc_nonascii)
specials.sort()
-print """c22_specials = """ + compact_set(specials) + """
+print("""c22_specials = """ + compact_set(specials) + """
def in_table_c22(code):
c = ord(code)
if c < 128: return False
@@ -300,7 +300,7 @@ def in_table_c22(code):
def in_table_c21_c22(code):
return unicodedata.category(code) == "Cc" or \\
ord(code) in c22_specials
-"""
+""")
# C.3 Private use
name, table = tables[0]
@@ -310,10 +310,10 @@ assert name == "C.3"
Co = set(gen_category(["Co"]))
assert set(table.keys()) == Co
-print """
+print("""
def in_table_c3(code):
return unicodedata.category(code) == "Co"
-"""
+""")
# C.4 Non-character code points, xFFFE, xFFFF
# plus process internal codes
@@ -327,13 +327,13 @@ nonchar = set(range(0xFDD0,0xFDF0) +
table = set(table.keys())
assert table == nonchar
-print """
+print("""
def in_table_c4(code):
c = ord(code)
if c < 0xFDD0: return False
if c < 0xFDF0: return True
return (ord(code) & 0xFFFF) in (0xFFFE, 0xFFFF)
-"""
+""")
# C.5 Surrogate codes
name, table = tables[0]
@@ -343,10 +343,10 @@ assert name == "C.5"
Cs = set(gen_category(["Cs"]))
assert set(table.keys()) == Cs
-print """
+print("""
def in_table_c5(code):
return unicodedata.category(code) == "Cs"
-"""
+""")
# C.6 Inappropriate for plain text
name, table = tables[0]
@@ -356,11 +356,11 @@ assert name == "C.6"
table = table.keys()
table.sort()
-print """
+print("""
c6_set = """ + compact_set(table) + """
def in_table_c6(code):
return ord(code) in c6_set
-"""
+""")
# C.7 Inappropriate for canonical representation
name, table = tables[0]
@@ -370,11 +370,11 @@ assert name == "C.7"
table = table.keys()
table.sort()
-print """
+print("""
c7_set = """ + compact_set(table) + """
def in_table_c7(code):
return ord(code) in c7_set
-"""
+""")
# C.8 Change display properties or are deprecated
name, table = tables[0]
@@ -384,11 +384,11 @@ assert name == "C.8"
table = table.keys()
table.sort()
-print """
+print("""
c8_set = """ + compact_set(table) + """
def in_table_c8(code):
return ord(code) in c8_set
-"""
+""")
# C.9 Tagging characters
name, table = tables[0]
@@ -398,11 +398,11 @@ assert name == "C.9"
table = table.keys()
table.sort()
-print """
+print("""
c9_set = """ + compact_set(table) + """
def in_table_c9(code):
return ord(code) in c9_set
-"""
+""")
# D.1 Characters with bidirectional property "R" or "AL"
name, table = tables[0]
@@ -412,10 +412,10 @@ assert name == "D.1"
RandAL = set(gen_bidirectional(["R","AL"]))
assert set(table.keys()) == RandAL
-print """
+print("""
def in_table_d1(code):
return unicodedata.bidirectional(code) in ("R","AL")
-"""
+""")
# D.2 Characters with bidirectional property "L"
name, table = tables[0]
@@ -425,7 +425,7 @@ assert name == "D.2"
L = set(gen_bidirectional(["L"]))
assert set(table.keys()) == L
-print """
+print("""
def in_table_d2(code):
return unicodedata.bidirectional(code) == "L"
-"""
+""")