Get the ASCII-armored key, given the ID

def gpg_export_key( appname, key_id, config_dir=None, include_private=False ):
    """
    Get the ASCII-armored key, given the ID
    """

    assert is_valid_appname(appname)
    config_dir = get_config_dir( config_dir )
    keydir = get_gpg_home( appname, config_dir=config_dir )
    gpg = gnupg.GPG( homedir=keydir )
    keydat = gpg.export_keys( [key_id], secret=include_private )

    if not keydat:
        log.debug("Failed to export key %s from '%s'" % (key_id, keydir))

    assert keydat
    return keydat