@@ -205,16 +205,16 @@ def get_numeric_value(self, cp):
205
205
class UnicodeTrieGenerator (object ):
206
206
# Note: if you change any of these parameters, don't forget to update the
207
207
# ASCII art above.
208
- BMP_first_level_index_bits = 8
208
+ bmp_first_level_index_bits = 8
209
209
210
210
supp_first_level_index_bits = 5
211
211
supp_second_level_index_bits = 8
212
212
213
213
def get_bmp_first_level_index (self , cp ):
214
- return cp >> self .BMP_data_offset_bits
214
+ return cp >> self .bmp_data_offset_bits
215
215
216
216
def get_bmp_data_offset (self , cp ):
217
- return cp & ((1 << self .BMP_data_offset_bits ) - 1 )
217
+ return cp & ((1 << self .bmp_data_offset_bits ) - 1 )
218
218
219
219
def get_supp_first_level_index (self , cp ):
220
220
return cp >> (self .supp_second_level_index_bits + self .supp_data_offset_bits )
@@ -235,7 +235,7 @@ def create_tables(self):
235
235
236
236
Don't change parameter values after calling this method.
237
237
"""
238
- self .BMP_data_offset_bits = 16 - self .BMP_first_level_index_bits
238
+ self .bmp_data_offset_bits = 16 - self .bmp_first_level_index_bits
239
239
240
240
self .supp_data_offset_bits = \
241
241
21 - self .supp_first_level_index_bits - \
@@ -250,12 +250,12 @@ def create_tables(self):
250
250
self .supp_data_offset_bits )
251
251
252
252
# A mapping from BMP first-level index to BMP data block index.
253
- self .BMP_lookup = [i for i in range (0 , 1 << self .BMP_first_level_index_bits )]
253
+ self .bmp_lookup = [i for i in range (0 , 1 << self .bmp_first_level_index_bits )]
254
254
255
255
# An array of BMP data blocks.
256
- self .BMP_data = [
257
- [- 1 for i in range (0 , 1 << self .BMP_data_offset_bits )]
258
- for i in range (0 , 1 << self .BMP_first_level_index_bits )
256
+ self .bmp_data = [
257
+ [- 1 for i in range (0 , 1 << self .bmp_data_offset_bits )]
258
+ for i in range (0 , 1 << self .bmp_first_level_index_bits )
259
259
]
260
260
261
261
# A mapping from supp first-level index to an index of the second-level
@@ -277,27 +277,27 @@ def create_tables(self):
277
277
]
278
278
279
279
def splat (self , value ):
280
- for i in range (0 , len (self .BMP_data )):
281
- for j in range (0 , len (self .BMP_data [i ])):
282
- self .BMP_data [i ][j ] = value
280
+ for i in range (0 , len (self .bmp_data )):
281
+ for j in range (0 , len (self .bmp_data [i ])):
282
+ self .bmp_data [i ][j ] = value
283
283
284
284
for i in range (0 , len (self .supp_data )):
285
285
for j in range (0 , len (self .supp_data [i ])):
286
286
self .supp_data [i ][j ] = value
287
287
288
288
def set_value (self , cp , value ):
289
289
if cp <= 0xffff :
290
- data_block_index = self .BMP_lookup [self .get_bmp_first_level_index (cp )]
291
- self .BMP_data [data_block_index ][self .get_bmp_data_offset (cp )] = value
290
+ data_block_index = self .bmp_lookup [self .get_bmp_first_level_index (cp )]
291
+ self .bmp_data [data_block_index ][self .get_bmp_data_offset (cp )] = value
292
292
else :
293
293
second_lookup_index = self .supp_lookup1 [self .get_supp_first_level_index (cp )]
294
294
data_block_index = self .supp_lookup2 [second_lookup_index ][self .get_supp_second_level_index (cp )]
295
295
self .supp_data [data_block_index ][self .get_supp_data_offset (cp )] = value
296
296
297
297
def get_value (self , cp ):
298
298
if cp <= 0xffff :
299
- data_block_index = self .BMP_lookup [self .get_bmp_first_level_index (cp )]
300
- return self .BMP_data [data_block_index ][self .get_bmp_data_offset (cp )]
299
+ data_block_index = self .bmp_lookup [self .get_bmp_first_level_index (cp )]
300
+ return self .bmp_data [data_block_index ][self .get_bmp_data_offset (cp )]
301
301
else :
302
302
second_lookup_index = self .supp_lookup1 [self .get_supp_first_level_index (cp )]
303
303
data_block_index = self .supp_lookup2 [second_lookup_index ][self .get_supp_second_level_index (cp )]
@@ -310,9 +310,9 @@ def fill_from_unicode_property(self, unicode_property):
310
310
311
311
def verify (self , unicode_property ):
312
312
for cp in range (0 , 0x110000 ):
313
- expectedValue = unicode_property .get_value (cp )
314
- actualValue = self .get_value (cp )
315
- assert (expectedValue == actualValue )
313
+ expected_value = unicode_property .get_value (cp )
314
+ actual_value = self .get_value (cp )
315
+ assert (expected_value == actual_value )
316
316
317
317
def freeze (self ):
318
318
"""Compress internal trie representation.
@@ -333,17 +333,17 @@ def map_index(idx):
333
333
# result of the `map` is explicitly converted to a `list`.
334
334
return list (map (map_index , indexes ))
335
335
336
- # If self.BMP_data contains identical data blocks, keep the first one,
337
- # remove duplicates and change the indexes in self.BMP_lookup to point to
336
+ # If self.bmp_data contains identical data blocks, keep the first one,
337
+ # remove duplicates and change the indexes in self.bmp_lookup to point to
338
338
# the first one.
339
339
i = 0
340
- while i < len (self .BMP_data ):
340
+ while i < len (self .bmp_data ):
341
341
j = i + 1
342
- while j < len (self .BMP_data ):
343
- if self .BMP_data [i ] == self .BMP_data [j ]:
344
- self .BMP_data .pop (j )
345
- self .BMP_lookup = \
346
- remap_indexes (self .BMP_lookup , old_idx = j , new_idx = i )
342
+ while j < len (self .bmp_data ):
343
+ if self .bmp_data [i ] == self .bmp_data [j ]:
344
+ self .bmp_data .pop (j )
345
+ self .bmp_lookup = \
346
+ remap_indexes (self .bmp_lookup , old_idx = j , new_idx = i )
347
347
else :
348
348
j += 1
349
349
i += 1
@@ -395,17 +395,17 @@ def _int_list_to_le_bytes(self, ints, width):
395
395
for byte in self ._int_to_le_bytes (elt , width )]
396
396
397
397
def serialize (self , unicode_property ):
398
- self .BMP_lookup_bytes_per_entry = 1 if len (self .BMP_data ) < 256 else 2
399
- self .BMP_data_bytes_per_entry = 1
398
+ self .bmp_lookup_bytes_per_entry = 1 if len (self .bmp_data ) < 256 else 2
399
+ self .bmp_data_bytes_per_entry = 1
400
400
401
401
self .supp_lookup1_bytes_per_entry = 1 if len (self .supp_lookup2 ) < 256 else 2
402
402
self .supp_lookup2_bytes_per_entry = 1 if len (self .supp_data ) < 256 else 2
403
403
self .supp_data_bytes_per_entry = 1
404
404
405
- BMP_lookup_words = list (self .BMP_lookup )
406
- BMP_data_words = [
405
+ bmp_lookup_words = list (self .bmp_lookup )
406
+ bmp_data_words = [
407
407
unicode_property .to_numeric_value (elt )
408
- for block in self .BMP_data
408
+ for block in self .bmp_data
409
409
for elt in block ]
410
410
411
411
supp_lookup1_words = list (self .supp_lookup1 )
@@ -415,10 +415,10 @@ def serialize(self, unicode_property):
415
415
for block in self .supp_data
416
416
for elt in block ]
417
417
418
- BMP_lookup_bytes = self ._int_list_to_le_bytes (
419
- BMP_lookup_words , self .BMP_lookup_bytes_per_entry )
420
- BMP_data_bytes = self ._int_list_to_le_bytes (
421
- BMP_data_words , self .BMP_data_bytes_per_entry )
418
+ bmp_lookup_bytes = self ._int_list_to_le_bytes (
419
+ bmp_lookup_words , self .bmp_lookup_bytes_per_entry )
420
+ bmp_data_bytes = self ._int_list_to_le_bytes (
421
+ bmp_data_words , self .bmp_data_bytes_per_entry )
422
422
423
423
supp_lookup1_bytes = self ._int_list_to_le_bytes (
424
424
supp_lookup1_words , self .supp_lookup1_bytes_per_entry )
@@ -429,11 +429,11 @@ def serialize(self, unicode_property):
429
429
430
430
self .trie_bytes = []
431
431
432
- self .BMP_lookup_bytes_offset = 0
433
- self .trie_bytes += BMP_lookup_bytes
432
+ self .bmp_lookup_bytes_offset = 0
433
+ self .trie_bytes += bmp_lookup_bytes
434
434
435
- self .BMP_data_bytes_offset = len (self .trie_bytes )
436
- self .trie_bytes += BMP_data_bytes
435
+ self .bmp_data_bytes_offset = len (self .trie_bytes )
436
+ self .trie_bytes += bmp_data_bytes
437
437
438
438
self .supp_lookup1_bytes_offset = len (self .trie_bytes )
439
439
self .trie_bytes += supp_lookup1_bytes
@@ -478,9 +478,9 @@ def get_extended_grapheme_cluster_rules_matrix(grapheme_cluster_break_property_t
478
478
dict .fromkeys (any_value , None )
479
479
480
480
# Iterate over rules in the order of increasing priority.
481
- for firstList , action , secondList in reversed (rules ):
482
- for first in firstList :
483
- for second in secondList :
481
+ for first_list , action , second_list in reversed (rules ):
482
+ for first in first_list :
483
+ for second in second_list :
484
484
rules_matrix [first ][second ] = action
485
485
486
486
# Make sure we can pack one row of the matrix into a 'uint16_t'.
@@ -532,10 +532,10 @@ def _convert_line(line):
532
532
if code_point >= 0xd800 and code_point <= 0xdfff :
533
533
code_point = 0x200b
534
534
code_point = (b'\U%(cp)08x' % {b'cp' : code_point }).decode ('unicode_escape' , 'strict' )
535
- as_UTF8_bytes = bytearray (code_point .encode ('utf8' , 'strict' ))
536
- as_UTF8_escaped = '' .join (['\\ x%(byte)02x' % {'byte' : byte } for byte in as_UTF8_bytes ])
537
- test += as_UTF8_escaped
538
- curr_bytes += len (as_UTF8_bytes )
535
+ as_utf8_bytes = bytearray (code_point .encode ('utf8' , 'strict' ))
536
+ as_utf8_escaped = '' .join (['\\ x%(byte)02x' % {'byte' : byte } for byte in as_utf8_bytes ])
537
+ test += as_utf8_escaped
538
+ curr_bytes += len (as_utf8_bytes )
539
539
540
540
return (test , boundaries )
541
541
0 commit comments