def init_table(key, method=None):
    if method is not None and method == 'table':
        method = None
    if method:
        try:
            __import__('M2Crypto')
        except ImportError:
            logging.error(('M2Crypto is required to use %s, please run'
                           ' `apt-get install python-m2crypto`') % method)
            sys.exit(1)
    if not method:
        if key in cached_tables:
            return cached_tables[key]
        encrypt_table = ''.join(get_table(key))
        decrypt_table = string.maketrans(encrypt_table,
                                         string.maketrans('', ''))
        cached_tables[key] = [encrypt_table, decrypt_table]
    else:
        try:
            Encryptor(key, method)  # test if the settings if OK
        except Exception as e:
            logging.error(e)
            sys.exit(1)
dataset/ETHPy150Open apporc/shadowsocks-gtk/shadowsocks_gtk/encrypt.py/init_table/original