diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-15 14:00:58 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-15 14:00:58 (GMT) |
commit | dc36472472361d8a360d97adbc7f1a3a8fce4493 (patch) | |
tree | 87b5391ab358d04c20da1ad0f8fa990d1f3fe3c2 /Tools/unicode/gencodec.py | |
parent | 358e7ff36b60ee933fbd913a8da9a9b55f8a90c9 (diff) | |
download | cpython-dc36472472361d8a360d97adbc7f1a3a8fce4493.zip cpython-dc36472472361d8a360d97adbc7f1a3a8fce4493.tar.gz cpython-dc36472472361d8a360d97adbc7f1a3a8fce4493.tar.bz2 |
Remove py3k deprecation warnings from these Unicode tools.
Diffstat (limited to 'Tools/unicode/gencodec.py')
-rw-r--r-- | Tools/unicode/gencodec.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Tools/unicode/gencodec.py b/Tools/unicode/gencodec.py index 431a76d..165c913 100644 --- a/Tools/unicode/gencodec.py +++ b/Tools/unicode/gencodec.py @@ -40,8 +40,7 @@ mapRE = re.compile('((?:0x[0-9a-fA-F]+\+?)+)' '\s*' '(#.+)?') -def parsecodes(codes, - len=len, filter=filter,range=range): +def parsecodes(codes, len=len, range=range): """ Converts code combinations to either a single code integer or a tuple of integers. @@ -62,7 +61,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: @@ -138,7 +137,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 +149,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 +197,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 @@ -421,6 +418,6 @@ if __name__ == '__main__': import sys if 1: - apply(convertdir,tuple(sys.argv[1:])) + convertdir(*sys.argv[1:]) else: - apply(rewritepythondir,tuple(sys.argv[1:])) + rewritepythondir(*sys.argv[1:]) |