@@ -89,7 +89,7 @@ def load_unicode_data(f):
8989 if is_surrogate (cp ):
9090 continue
9191 if range_start >= 0 :
92- for i in xrange (range_start , cp ):
92+ for i in range (range_start , cp ):
9393 udict [i ] = data
9494 range_start = - 1
9595 if data [1 ].endswith (", First>" ):
@@ -382,7 +382,7 @@ def compute_trie(rawdata, chunksize):
382382 root = []
383383 childmap = {}
384384 child_data = []
385- for i in range (len (rawdata ) / chunksize ):
385+ for i in range (len (rawdata ) // chunksize ):
386386 data = rawdata [i * chunksize : (i + 1 ) * chunksize ]
387387 child = '|' .join (map (str , data ))
388388 if child not in childmap :
@@ -400,7 +400,7 @@ def emit_bool_trie(f, name, t_data, is_pub=True):
400400
401401 # convert to bitmap chunks of 64 bits each
402402 chunks = []
403- for i in range (0x110000 / CHUNK ):
403+ for i in range (0x110000 // CHUNK ):
404404 chunk = 0
405405 for j in range (64 ):
406406 if rawdata [i * 64 + j ]:
@@ -412,12 +412,12 @@ def emit_bool_trie(f, name, t_data, is_pub=True):
412412 pub_string = "pub "
413413 f .write (" %sconst %s: &'static super::BoolTrie = &super::BoolTrie {\n " % (pub_string , name ))
414414 f .write (" r1: [\n " )
415- data = ',' .join ('0x%016x' % chunk for chunk in chunks [0 :0x800 / CHUNK ])
415+ data = ',' .join ('0x%016x' % chunk for chunk in chunks [0 :0x800 // CHUNK ])
416416 format_table_content (f , data , 12 )
417417 f .write ("\n ],\n " )
418418
419419 # 0x800..0x10000 trie
420- (r2 , r3 ) = compute_trie (chunks [0x800 / CHUNK : 0x10000 / CHUNK ], 64 / CHUNK )
420+ (r2 , r3 ) = compute_trie (chunks [0x800 // CHUNK : 0x10000 // CHUNK ], 64 / / CHUNK )
421421 f .write (" r2: [\n " )
422422 data = ',' .join (str (node ) for node in r2 )
423423 format_table_content (f , data , 12 )
@@ -428,7 +428,7 @@ def emit_bool_trie(f, name, t_data, is_pub=True):
428428 f .write ("\n ],\n " )
429429
430430 # 0x10000..0x110000 trie
431- (mid , r6 ) = compute_trie (chunks [0x10000 / CHUNK : 0x110000 / CHUNK ], 64 / CHUNK )
431+ (mid , r6 ) = compute_trie (chunks [0x10000 // CHUNK : 0x110000 // CHUNK ], 64 / / CHUNK )
432432 (r4 , r5 ) = compute_trie (mid , 64 )
433433 f .write (" r4: [\n " )
434434 data = ',' .join (str (node ) for node in r4 )
@@ -446,14 +446,14 @@ def emit_bool_trie(f, name, t_data, is_pub=True):
446446 f .write (" };\n \n " )
447447
448448def emit_small_bool_trie (f , name , t_data , is_pub = True ):
449- last_chunk = max (int ( hi / 64 ) for (lo , hi ) in t_data )
449+ last_chunk = max (hi // 64 for (lo , hi ) in t_data )
450450 n_chunks = last_chunk + 1
451451 chunks = [0 ] * n_chunks
452452 for (lo , hi ) in t_data :
453453 for cp in range (lo , hi + 1 ):
454- if int ( cp / 64 ) >= len (chunks ):
455- print (cp , int ( cp / 64 ) , len (chunks ), lo , hi )
456- chunks [int ( cp / 64 ) ] |= 1 << (cp & 63 )
454+ if cp // 64 >= len (chunks ):
455+ print (cp , cp // 64 , len (chunks ), lo , hi )
456+ chunks [cp // 64 ] |= 1 << (cp & 63 )
457457
458458 pub_string = ""
459459 if is_pub :
@@ -519,32 +519,29 @@ def emit_conversions_module(f, to_upper, to_lower, to_title):
519519 pfun = lambda x : "(%s,[%s,%s,%s])" % (
520520 escape_char (x [0 ]), escape_char (x [1 ][0 ]), escape_char (x [1 ][1 ]), escape_char (x [1 ][2 ]))
521521 emit_table (f , "to_lowercase_table" ,
522- sorted (to_lower .iteritems (), key = operator .itemgetter (0 )),
522+ sorted (to_lower .items (), key = operator .itemgetter (0 )),
523523 is_pub = False , t_type = t_type , pfun = pfun )
524524 emit_table (f , "to_uppercase_table" ,
525- sorted (to_upper .iteritems (), key = operator .itemgetter (0 )),
525+ sorted (to_upper .items (), key = operator .itemgetter (0 )),
526526 is_pub = False , t_type = t_type , pfun = pfun )
527527 f .write ("}\n \n " )
528528
529529def emit_norm_module (f , canon , compat , combine , norm_props ):
530- canon_keys = canon .keys ()
531- canon_keys .sort ()
530+ canon_keys = sorted (canon .keys ())
532531
533- compat_keys = compat .keys ()
534- compat_keys .sort ()
532+ compat_keys = sorted (compat .keys ())
535533
536534 canon_comp = {}
537535 comp_exclusions = norm_props ["Full_Composition_Exclusion" ]
538536 for char in canon_keys :
539- if True in map ( lambda ( lo , hi ): lo <= char <= hi , comp_exclusions ):
537+ if any ( lo <= char <= hi for lo , hi in comp_exclusions ):
540538 continue
541539 decomp = canon [char ]
542540 if len (decomp ) == 2 :
543- if not canon_comp . has_key ( decomp [0 ]) :
541+ if decomp [0 ] not in canon_comp :
544542 canon_comp [decomp [0 ]] = []
545543 canon_comp [decomp [0 ]].append ( (decomp [1 ], char ) )
546- canon_comp_keys = canon_comp .keys ()
547- canon_comp_keys .sort ()
544+ canon_comp_keys = sorted (canon_comp .keys ())
548545
549546if __name__ == "__main__" :
550547 r = "tables.rs"
0 commit comments