def get_keys(install=False, trust=False, force=False):
    '\n    Get pgp public keys available on mirror\n    with suffix .key or .pub\n    '
    if (not spack.mirror.MirrorCollection()):
        tty.die(('Please add a spack mirror to allow ' + 'download of build caches.'))
    keys = set()
    for mirror in spack.mirror.MirrorCollection().values():
        fetch_url_build_cache = url_util.join(mirror.fetch_url, _build_cache_relative_path)
        mirror_dir = url_util.local_file_path(fetch_url_build_cache)
        if mirror_dir:
            tty.msg(('Finding public keys in %s' % mirror_dir))
            files = os.listdir(str(mirror_dir))
            for file in files:
                if (re.search('\\.key', file) or re.search('\\.pub', file)):
                    link = url_util.join(fetch_url_build_cache, file)
                    keys.add(link)
        else:
            tty.msg(('Finding public keys at %s' % url_util.format(fetch_url_build_cache)))
            (p, links) = web_util.spider(url_util.join(fetch_url_build_cache, 'index.html'), depth=1)
            for link in links:
                if (re.search('\\.key', link) or re.search('\\.pub', link)):
                    keys.add(link)
        for link in keys:
            with Stage(link, name='build_cache', keep=True) as stage:
                if (os.path.exists(stage.save_filename) and force):
                    os.remove(stage.save_filename)
                if (not os.path.exists(stage.save_filename)):
                    try:
                        stage.fetch()
                    except fs.FetchError:
                        continue
            tty.msg(('Found key %s' % link))
            if install:
                if trust:
                    Gpg.trust(stage.save_filename)
                    tty.msg('Added this key to trusted keys.')
                else:
                    tty.msg('Will not add this key to trusted keys.Use -t to install all downloaded keys')
Get pgp public keys available on mirror
with suffix .key or .pub
def get_keys(install=False, trust=False, force=False):
    '\n    Get pgp public keys available on mirror\n    with suffix .key or .pub\n    '
    if (not spack.mirror.MirrorCollection()):
        tty.die(('Please add a spack mirror to allow ' + 'download of build caches.'))
    keys = set()
    for mirror in spack.mirror.MirrorCollection().values():
        fetch_url_build_cache = url_util.join(mirror.fetch_url, _build_cache_relative_path)
        mirror_dir = url_util.local_file_path(fetch_url_build_cache)
        if mirror_dir:
            tty.msg(('Finding public keys in %s' % mirror_dir))
            files = os.listdir(str(mirror_dir))
            for file in files:
                if (re.search('\\.key', file) or re.search('\\.pub', file)):
                    link = url_util.join(fetch_url_build_cache, file)
                    keys.add(link)
        else:
            tty.msg(('Finding public keys at %s' % url_util.format(fetch_url_build_cache)))
            (p, links) = web_util.spider(url_util.join(fetch_url_build_cache, 'index.html'), depth=1)
            for link in links:
                if (re.search('\\.key', link) or re.search('\\.pub', link)):
                    keys.add(link)
        for link in keys:
            with Stage(link, name='build_cache', keep=True) as stage:
                if (os.path.exists(stage.save_filename) and force):
                    os.remove(stage.save_filename)
                if (not os.path.exists(stage.save_filename)):
                    try:
                        stage.fetch()
                    except fs.FetchError:
                        continue
            tty.msg(('Found key %s' % link))
            if install:
                if trust:
                    Gpg.trust(stage.save_filename)
                    tty.msg('Added this key to trusted keys.')
                else:
                    tty.msg('Will not add this key to trusted keys.Use -t to install all downloaded keys')