<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> from nototools import unicode_data <EOL> OMPL = { } <EOL> def _set_ompl ( ) : <EOL> """<STR_LIT>""" <EOL> global OMPL <EOL> unicode_data . load_data ( ) <EOL> bmg_data = unicode_data . _bidi_mirroring_glyph_data <EOL> OMPL = { char : bmg for ( char , bmg ) in bmg_data . items ( ) <EOL> if float ( unicode_data . age ( char ) ) <= <NUM_LIT> } <EOL> ZWSP = [ <NUM_LIT> ] <EOL> JOINERS = [ <NUM_LIT> , <NUM_LIT> ] <EOL> BIDI_MARKS = [ <NUM_LIT> , <NUM_LIT> ] <EOL> DOTTED_CIRCLE = [ <NUM_LIT> ] <EOL> SPECIAL_CHARACTERS_NEEDED = { <EOL> '<STR_LIT>' : JOINERS + BIDI_MARKS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : BIDI_MARKS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : JOINERS + BIDI_MARKS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : BIDI_MARKS + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + DOTTED_CIRCLE , <EOL> '<STR_LIT>' : ZWSP + JOINERS + DOTTED_CIRCLE , <EOL> } <EOL> _unicoderange_data = """<STR_LIT>""" <EOL> ur_data = [ ] <EOL> ur_bucket_info = [ [ ] for i in range ( <NUM_LIT> ) ] <EOL> def _setup_unicoderange_data ( ) : <EOL> """<STR_LIT>""" <EOL> if ur_data : <EOL> return <EOL> index = <NUM_LIT:0> <EOL> for line in _unicoderange_data . splitlines ( ) : <EOL> index_str , name , urange = line . split ( '<STR_LIT:\t>' ) <EOL> range_start_str , range_end_str = urange . split ( '<STR_LIT:->' ) <EOL> range_start = int ( range_start_str , <NUM_LIT:16> ) <EOL> range_end = int ( range_end_str , <NUM_LIT:16> ) <EOL> if index_str : <EOL> index = int ( index_str ) <EOL> tup = ( range_start , range_end , index , name ) <EOL> ur_data . append ( tup ) <EOL> ur_bucket_info [ index ] . append ( tup ) <EOL> ur_data . sort ( ) <EOL> def collect_unicoderange_info ( cmap ) : <EOL> """<STR_LIT>""" <EOL> _setup_unicoderange_data ( ) <EOL> range_count = <NUM_LIT:0> <EOL> index = <NUM_LIT:0> <EOL> limit = len ( ur_data ) <EOL> result = [ ] <EOL> for cp in sorted ( cmap ) : <EOL> while index < limit : <EOL> tup = ur_data [ index ] <EOL> if cp <= tup [ <NUM_LIT:1> ] : <EOL> if cp >= tup [ <NUM_LIT:0> ] : <EOL> range_count += <NUM_LIT:1> <EOL> break <EOL> if range_count : <EOL> result . append ( ( range_count , ur_data [ index ] ) ) <EOL> range_count = <NUM_LIT:0> <EOL> index += <NUM_LIT:1> <EOL> if range_count : <EOL> result . append ( ( range_count , ur_data [ index ] ) ) <EOL> return result <EOL> def unicoderange_bucket_info_name ( bucket_info ) : <EOL> return '<STR_LIT:U+002CU+0020>' . join ( t [ <NUM_LIT:3> ] for t in bucket_info ) <EOL> def unicoderange_bucket_info_size ( bucket_info ) : <EOL> return sum ( t [ <NUM_LIT:1> ] - t [ <NUM_LIT:0> ] + <NUM_LIT:1> for t in bucket_info ) <EOL> def unicoderange_bucket_index_to_info ( bucket_index ) : <EOL> if bucket_index < <NUM_LIT:0> or bucket_index >= <NUM_LIT> : <EOL> raise ValueError ( '<STR_LIT>' % bucket_index ) <EOL> _setup_unicoderange_data ( ) <EOL> return ur_bucket_info [ bucket_index ] <EOL> def unicoderange_bucket_index_to_name ( bucket_index ) : <EOL> return unicoderange_bucket_info_name ( unicoderange_bucket_index_to_info ( bucket_index ) ) <EOL> if not OMPL : <EOL> _set_ompl ( ) </s>
