

def load_keypair():
    'Try to load a keypair that exists in ~/.ravello.'
    cfgdir = util.get_config_dir()
    privname = os.path.join(cfgdir, 'id_ravello')
    try:
        st = os.stat(privname)
    except OSError:
        return
    if (not stat.S_ISREG(st.st_mode)):
        error.raise_error('Private key {0} is not a regular file.', pivname)
    pubname = (privname + '.pub')
    try:
        st = os.stat(pubname)
    except OSError:
        st = None
    if (st is None):
        error.raise_error('Public key {0} does not exist.', pubname)
    elif (not stat.S_ISREG(st.st_mode)):
        error.raise_error('Public key {0} is not a regular file.', pubname)
    with file(pubname) as fin:
        pubkey = fin.read()
    keyparts = pubkey.strip().split()
    pubkeys = env.api.get_pubkeys()
    for pubkey in pubkeys:
        if (pubkey['name'] == keyparts[2]):
            env.public_key = pubkey
            env.private_key_file = privname
            return pubkey

dataset/ETHPy150Open ravello/testmill/lib/testmill/keypair.py load_keypair/original