summaryrefslogtreecommitdiffstats
path: root/Tools/unicode/gencodec.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/unicode/gencodec.py')
-rw-r--r--Tools/unicode/gencodec.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/Tools/unicode/gencodec.py b/Tools/unicode/gencodec.py
index c63f559..c3846e9 100644
--- a/Tools/unicode/gencodec.py
+++ b/Tools/unicode/gencodec.py
@@ -32,7 +32,7 @@ import re, os, marshal, codecs
MAX_TABLE_SIZE = 8192
# Standard undefined Unicode code point
-UNI_UNDEFINED = unichr(0xFFFE)
+UNI_UNDEFINED = chr(0xFFFE)
mapRE = re.compile('((?:0x[0-9a-fA-F]+\+?)+)'
'\s+'
@@ -62,7 +62,7 @@ def parsecodes(codes,
l[i] = int(l[i],16)
except ValueError:
l[i] = None
- l = filter(lambda x: x is not None, l)
+ l = [x for x in l if x is not None]
if len(l) == 1:
return l[0]
else:
@@ -75,12 +75,12 @@ def readmap(filename):
f.close()
enc2uni = {}
identity = []
- unmapped = range(256)
+ unmapped = list(range(256))
# UTC mapping tables per convention don't include the identity
# mappings for code points 0x00 - 0x1F and 0x7F, unless these are
# explicitly mapped to different characters or undefined
- for i in range(32) + [127]:
+ for i in list(range(32)) + [127]:
identity.append(i)
unmapped.remove(i)
enc2uni[i] = (i, 'CONTROL CHARACTER')
@@ -138,7 +138,7 @@ def python_mapdef_code(varname, map, comments=1, precisions=(2, 4)):
l = []
append = l.append
- if map.has_key("IDENTITY"):
+ if "IDENTITY" in map:
append("%s = codecs.make_identity_dict(range(%d))" %
(varname, map["IDENTITY"]))
append("%s.update({" % varname)
@@ -150,8 +150,7 @@ def python_mapdef_code(varname, map, comments=1, precisions=(2, 4)):
splits = 0
identity = 0
- mappings = map.items()
- mappings.sort()
+ mappings = sorted(map.items())
i = 0
key_precision, value_precision = precisions
for mapkey, mapvalue in mappings:
@@ -199,11 +198,10 @@ def python_tabledef_code(varname, map, comments=1, key_precision=2):
append('%s = (' % varname)
# Analyze map and create table dict
- mappings = map.items()
- mappings.sort()
+ mappings = sorted(map.items())
table = {}
maxkey = 0
- if map.has_key('IDENTITY'):
+ if 'IDENTITY' in map:
for key in range(256):
table[key] = (key, '')
maxkey = 255
@@ -237,7 +235,7 @@ def python_tabledef_code(varname, map, comments=1, key_precision=2):
# 1-n mappings not supported
return None
else:
- mapchar = unichr(mapvalue)
+ mapchar = chr(mapvalue)
if mapcomment and comments:
append(' %r\t# %s -> %s' % (mapchar,
hexrepr(key, key_precision),