@@ -89,7 +89,7 @@ def load_unicode_data(f):
89
89
if is_surrogate (cp ):
90
90
continue
91
91
if range_start >= 0 :
92
- for i in xrange (range_start , cp ):
92
+ for i in range (range_start , cp ):
93
93
udict [i ] = data
94
94
range_start = - 1
95
95
if data [1 ].endswith (", First>" ):
@@ -382,7 +382,7 @@ def compute_trie(rawdata, chunksize):
382
382
root = []
383
383
childmap = {}
384
384
child_data = []
385
- for i in range (len (rawdata ) / chunksize ):
385
+ for i in range (len (rawdata ) // chunksize ):
386
386
data = rawdata [i * chunksize : (i + 1 ) * chunksize ]
387
387
child = '|' .join (map (str , data ))
388
388
if child not in childmap :
@@ -400,7 +400,7 @@ def emit_bool_trie(f, name, t_data, is_pub=True):
400
400
401
401
# convert to bitmap chunks of 64 bits each
402
402
chunks = []
403
- for i in range (0x110000 / CHUNK ):
403
+ for i in range (0x110000 // CHUNK ):
404
404
chunk = 0
405
405
for j in range (64 ):
406
406
if rawdata [i * 64 + j ]:
@@ -412,12 +412,12 @@ def emit_bool_trie(f, name, t_data, is_pub=True):
412
412
pub_string = "pub "
413
413
f .write (" %sconst %s: &'static super::BoolTrie = &super::BoolTrie {\n " % (pub_string , name ))
414
414
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 ])
416
416
format_table_content (f , data , 12 )
417
417
f .write ("\n ],\n " )
418
418
419
419
# 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 )
421
421
f .write (" r2: [\n " )
422
422
data = ',' .join (str (node ) for node in r2 )
423
423
format_table_content (f , data , 12 )
@@ -428,7 +428,7 @@ def emit_bool_trie(f, name, t_data, is_pub=True):
428
428
f .write ("\n ],\n " )
429
429
430
430
# 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 )
432
432
(r4 , r5 ) = compute_trie (mid , 64 )
433
433
f .write (" r4: [\n " )
434
434
data = ',' .join (str (node ) for node in r4 )
@@ -446,14 +446,14 @@ def emit_bool_trie(f, name, t_data, is_pub=True):
446
446
f .write (" };\n \n " )
447
447
448
448
def 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 )
450
450
n_chunks = last_chunk + 1
451
451
chunks = [0 ] * n_chunks
452
452
for (lo , hi ) in t_data :
453
453
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 )
457
457
458
458
pub_string = ""
459
459
if is_pub :
@@ -519,32 +519,29 @@ def emit_conversions_module(f, to_upper, to_lower, to_title):
519
519
pfun = lambda x : "(%s,[%s,%s,%s])" % (
520
520
escape_char (x [0 ]), escape_char (x [1 ][0 ]), escape_char (x [1 ][1 ]), escape_char (x [1 ][2 ]))
521
521
emit_table (f , "to_lowercase_table" ,
522
- sorted (to_lower .iteritems (), key = operator .itemgetter (0 )),
522
+ sorted (to_lower .items (), key = operator .itemgetter (0 )),
523
523
is_pub = False , t_type = t_type , pfun = pfun )
524
524
emit_table (f , "to_uppercase_table" ,
525
- sorted (to_upper .iteritems (), key = operator .itemgetter (0 )),
525
+ sorted (to_upper .items (), key = operator .itemgetter (0 )),
526
526
is_pub = False , t_type = t_type , pfun = pfun )
527
527
f .write ("}\n \n " )
528
528
529
529
def emit_norm_module (f , canon , compat , combine , norm_props ):
530
- canon_keys = canon .keys ()
531
- canon_keys .sort ()
530
+ canon_keys = sorted (canon .keys ())
532
531
533
- compat_keys = compat .keys ()
534
- compat_keys .sort ()
532
+ compat_keys = sorted (compat .keys ())
535
533
536
534
canon_comp = {}
537
535
comp_exclusions = norm_props ["Full_Composition_Exclusion" ]
538
536
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 ):
540
538
continue
541
539
decomp = canon [char ]
542
540
if len (decomp ) == 2 :
543
- if not canon_comp . has_key ( decomp [0 ]) :
541
+ if decomp [0 ] not in canon_comp :
544
542
canon_comp [decomp [0 ]] = []
545
543
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 ())
548
545
549
546
if __name__ == "__main__" :
550
547
r = "tables.rs"
0 commit comments