<s> from sys import version <EOL> PYTHON3 = version > '<STR_LIT:3>' <EOL> del version <EOL> try : <EOL> from . orddic import OrderedDict <EOL> except ImportError as ime : <EOL> from collections import OrderedDict <EOL> from . encode2utf8 import anjal2utf8 , bamini2utf8 , boomi2utf8 , dinakaran2utf8 , dinamani2utf8 , dinathanthy2utf8 , kavipriya2utf8 , murasoli2utf8 , mylai2utf8 , nakkeeran2utf8 , roman2utf8 , tab2utf8 , tam2utf8 , tscii2utf8 , pallavar2utf8 , indoweb2utf8 , koeln2utf8 , libi2utf8 , oldvikatan2utf8 , webulagam2utf8 , diacritic2utf8 , shreelipi2utf8 , softview2utf8 , tace2utf8 , vanavil2utf8 , indica2utf8 , anu2utf8 , shreelipiavid2utf8 <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> _all_encodes_ = OrderedDict ( [ ( '<STR_LIT>' , anjal2utf8 ) , <EOL> ( '<STR_LIT>' , bamini2utf8 ) , ( '<STR_LIT>' , boomi2utf8 ) , <EOL> ( '<STR_LIT>' , dinakaran2utf8 ) , ( '<STR_LIT>' , dinamani2utf8 ) , <EOL> ( '<STR_LIT>' , dinathanthy2utf8 ) , <EOL> ( '<STR_LIT>' , kavipriya2utf8 ) , ( '<STR_LIT>' , murasoli2utf8 ) , <EOL> ( '<STR_LIT>' , mylai2utf8 ) , ( '<STR_LIT>' , nakkeeran2utf8 ) , <EOL> ( '<STR_LIT>' , roman2utf8 ) , ( '<STR_LIT>' , tab2utf8 ) , <EOL> ( '<STR_LIT>' , tam2utf8 ) , ( '<STR_LIT>' , tscii2utf8 ) , <EOL> ( '<STR_LIT>' , pallavar2utf8 ) , ( '<STR_LIT>' , indoweb2utf8 ) , <EOL> ( '<STR_LIT>' , koeln2utf8 ) , ( '<STR_LIT>' , libi2utf8 ) , <EOL> ( '<STR_LIT>' , oldvikatan2utf8 ) , ( '<STR_LIT>' , webulagam2utf8 ) , <EOL> ( '<STR_LIT>' , diacritic2utf8 ) , ( '<STR_LIT>' , shreelipi2utf8 ) , <EOL> ( '<STR_LIT>' , softview2utf8 ) , ( '<STR_LIT>' , tace2utf8 ) , <EOL> ( '<STR_LIT>' , vanavil2utf8 ) , ( '<STR_LIT>' , indica2utf8 ) <EOL> ] ) <EOL> __WRITE_CHARS_TXT = False <EOL> def encode2unicode ( text , charmap ) : <EOL> '''<STR_LIT>''' <EOL> if isinstance ( text , ( list , tuple ) ) : <EOL> unitxt = '<STR_LIT>' <EOL> for line in text : <EOL> for key , val in charmap . items ( ) : <EOL> if key in line : <EOL> line = line . replace ( key , val ) <EOL> unitxt += line <EOL> return unitxt <EOL> elif isinstance ( text , str ) : <EOL> for key , val in charmap . items ( ) : <EOL> if key in text : <EOL> text = text . replace ( key , val ) <EOL> return text <EOL> raise Exception ( "<STR_LIT>" ) <EOL> def anjal2unicode ( text ) : <EOL> return encode2unicode ( text , anjal2utf8 ) <EOL> def bamini2unicode ( text ) : <EOL> return encode2unicode ( text , bamini2utf8 ) <EOL> def boomi2unicode ( text ) : <EOL> return encode2unicode ( text , boomi2utf8 ) <EOL> def dinakaran2unicode ( text ) : <EOL> return encode2unicode ( text , dinakaran2utf8 ) <EOL> def dinamani2unicode ( text ) : <EOL> return encode2unicode ( text , dinamani2utf8 ) <EOL> def dinathanthy2unicode ( text ) : <EOL> return encode2unicode ( text , dinathanthy2utf8 ) <EOL> def kavipriya2unicode ( text ) : <EOL> return encode2unicode ( text , kavipriya2utf8 ) <EOL> def murasoli2unicode ( text ) : <EOL> return encode2unicode ( text , murasoli2utf8 ) <EOL> def mylai2unicode ( text ) : <EOL> return encode2unicode ( text , mylai2utf8 ) <EOL> def nakkeeran2unicode ( text ) : <EOL> return encode2unicode ( text , nakkeeran2utf8 ) <EOL> def roman2unicode ( text ) : <EOL> return encode2unicode ( text , roman2utf8 ) <EOL> def tab2unicode ( text ) : <EOL> return encode2unicode ( text , tab2utf8 ) <EOL> def tam2unicode ( text ) : <EOL> return encode2unicode ( text , tam2utf8 ) <EOL> def tscii2unicode ( text ) : <EOL> return encode2unicode ( text , tscii2utf8 ) <EOL> def pallavar2unicode ( text ) : <EOL> return encode2unicode ( text , pallavar2utf8 ) <EOL> def indoweb2unicode ( text ) : <EOL> return encode2unicode ( text , indoweb2utf8 ) <EOL> def koeln2unicode ( text ) : <EOL> return encode2unicode ( text , koeln2utf8 ) <EOL> def libi2unicode ( text ) : <EOL> return encode2unicode ( text , libi2utf8 ) <EOL> def oldvikatan2unicode ( text ) : <EOL> return encode2unicode ( text , oldvikatan2utf8 ) <EOL> def webulagam2unicode ( text ) : <EOL> return encode2unicode ( text , webulagam2utf8 ) <EOL> def diacritic2unicode ( text ) : <EOL> return encode2unicode ( text , diacritic2utf8 ) <EOL> def shreelipi2unicode ( text ) : <EOL> return encode2unicode ( text , shreelipi2utf8 ) <EOL> def softview2unicode ( text ) : <EOL> return encode2unicode ( text , softview2utf8 ) <EOL> def tace2unicode ( text ) : <EOL> return encode2unicode ( text , tace2utf8 ) <EOL> def vanavil2unicode ( text ) : <EOL> return encode2unicode ( text , vanavil2utf8 ) <EOL> def indica2unicode ( text ) : <EOL> return encode2unicode ( text , indica2utf8 ) <EOL> def anu2unicode ( text ) : <EOL> return encode2unicode ( text , anu2utf8 ) <EOL> def shreelipiavid2unicode ( text ) : <EOL> return encode2unicode ( text , shreelipiavid2utf8 ) <EOL> def _get_unique_ch ( text , all_common_encodes ) : <EOL> """<STR_LIT>""" <EOL> unique_chars = '<STR_LIT>' <EOL> if isinstance ( text , str ) : <EOL> text = text . split ( "<STR_LIT:\n>" ) <EOL> elif isinstance ( text , ( list , tuple ) ) : <EOL> pass <EOL> special_chars = [ '<STR_LIT:.>' , '<STR_LIT:U+002C>' , '<STR_LIT:;>' , '<STR_LIT::>' , '<STR_LIT>' , '<STR_LIT:U+0020>' , '<STR_LIT:\r>' , '<STR_LIT:\t>' , '<STR_LIT:=>' , '<STR_LIT:\n>' ] <EOL> for line in text : <EOL> for word in line . split ( '<STR_LIT:U+0020>' ) : <EOL> if ( not PYTHON3 ) : word = word . decode ( '<STR_LIT:utf-8>' ) <EOL> for ch in all_common_encodes : <EOL> if ch in word : word = word . replace ( ch , '<STR_LIT>' ) <EOL> if not word : continue <EOL> for ch in word : <EOL> if ch . isdigit ( ) or ch in special_chars : <EOL> word = word . replace ( ch , '<STR_LIT>' ) <EOL> continue <EOL> return word <EOL> return '<STR_LIT>' <EOL> def _get_unique_common_encodes ( ) : <EOL> """<STR_LIT>""" <EOL> _all_unique_encodes_ = [ ] <EOL> _all_unicode_encodes_ = { } <EOL> _all_common_encodes_ = set ( [ ] ) <EOL> _all_common_encodes_single_char_ = set ( [ ] ) <EOL> for name , encode in _all_encodes_ . items ( ) : <EOL> encode_utf8 = set ( [ PYTHON3 and ch or ch . decode ( '<STR_LIT:utf-8>' ) for ch in encode . keys ( ) ] ) <EOL> _all_unicode_encodes_ [ name ] = encode_utf8 <EOL> _all_unique_encodes_full_ = _all_unicode_encodes_ . copy ( ) <EOL> for supname , super_encode in _all_unicode_encodes_ . items ( ) : <EOL> for subname , sub_encode in _all_unicode_encodes_ . items ( ) : <EOL> if supname == subname : continue <EOL> super_encode = super_encode - sub_encode <EOL> common = _all_unique_encodes_full_ [ supname ] - super_encode <EOL> _all_common_encodes_ = _all_common_encodes_ . union ( common ) <EOL> _all_unique_encodes_ . append ( ( supname , super_encode ) ) <EOL> for ch in _all_common_encodes_ : <EOL> if len ( ch ) == <NUM_LIT:1> : _all_common_encodes_single_char_ . add ( ch ) <EOL> _all_common_encodes_ -= _all_common_encodes_single_char_ <EOL> if __WRITE_CHARS_TXT : <EOL> f = open ( '<STR_LIT>' , '<STR_LIT:w>' ) <EOL> for ch in _all_common_encodes_ : <EOL> ch = ch . encode ( '<STR_LIT:utf-8>' ) <EOL> for encode_keys in _all_encodes_ . values ( ) : <EOL> if ch in encode_keys : <EOL> uni = encode_keys [ ch ] <EOL> break <EOL> f . write ( ch + '<STR_LIT>' + uni + '<STR_LIT:\n>' ) <EOL> f . close ( ) <EOL> for encode_name , encode_keys in _all_unique_encodes_ : <EOL> f = open ( encode_name + '<STR_LIT>' , '<STR_LIT:w>' ) <EOL> for ch in encode_keys : <EOL> ch = ch . encode ( '<STR_LIT:utf-8>' ) <EOL> uni = _all_encodes_ [ encode_name ] [ ch ] <EOL> f . write ( ch + '<STR_LIT>' + uni + '<STR_LIT:\n>' ) <EOL> f . close ( ) <EOL> return ( _all_unique_encodes_ , _all_common_encodes_ ) <EOL> def auto2unicode ( text ) : <EOL> """<STR_LIT>""" <EOL> _all_unique_encodes_ , _all_common_encodes_ = _get_unique_common_encodes ( ) <EOL> unique_chars = _get_unique_ch ( text , _all_common_encodes_ ) <EOL> clen = len ( _all_common_encodes_ ) <EOL> msg = "<STR_LIT>" <EOL> msg += '<STR_LIT>' % clen <EOL> msg += '<STR_LIT>' <EOL> if not unique_chars : <EOL> print ( msg ) <EOL> return '<STR_LIT>' <EOL> for encode_name , encode_keys in _all_unique_encodes_ : <EOL> if not len ( encode_keys ) : continue <EOL> for ch in encode_keys : <EOL> if ch in unique_chars : <EOL> print ( ( "<STR_LIT>" , encode_name ) ) <EOL> encode = _all_encodes_ [ encode_name ] <EOL> return encode2unicode ( text , encode ) <EOL> else : <EOL> print ( msg ) <EOL> return '<STR_LIT>' </s>
