def addresses_for_key(gpg_keychain, key):
    """
    Takes a key and extracts its email addresses.
    """
    fingerprint = key['fingerprint']
    addresses = []
    for key in gpg_keychain.list_keys():
        if key['fingerprint'] == fingerprint:
            # parse raw email addresses (without preceding name)
            addresses.extend([address.split('<')[-1].strip('>') for address in key['uids'] if address])
    assert len(addresses) > 0
    return addresses