def generate_package_index(cache_prefix):
    'Create the build cache index page.\n\n    Creates (or replaces) the "index.html" page at the location given in\n    cache_prefix.  This page contains a link for each binary package (*.yaml)\n    and public key (*.key) under cache_prefix.\n    '
    tmpdir = tempfile.mkdtemp()
    try:
        index_html_path = os.path.join(tmpdir, 'index.html')
        file_list = (entry for entry in web_util.list_url(cache_prefix) if (entry.endswith('.yaml') or entry.endswith('.key')))
        with open(index_html_path, 'w') as f:
            f.write(BUILD_CACHE_INDEX_TEMPLATE.format(title='Spack Package Index', path_list='\n'.join((BUILD_CACHE_INDEX_ENTRY_TEMPLATE.format(path=path) for path in file_list))))
        web_util.push_to_url(index_html_path, url_util.join(cache_prefix, 'index.html'), keep_original=False, extra_args={'ContentType': 'text/html'})
    finally:
        shutil.rmtree(tmpdir)
Create the build cache index page.

Creates (or replaces) the "index.html" page at the location given in
cache_prefix.  This page contains a link for each binary package (*.yaml)
and public key (*.key) under cache_prefix.
def generate_package_index(cache_prefix):
    'Create the build cache index page.\n\n    Creates (or replaces) the "index.html" page at the location given in\n    cache_prefix.  This page contains a link for each binary package (*.yaml)\n    and public key (*.key) under cache_prefix.\n    '
    tmpdir = tempfile.mkdtemp()
    try:
        index_html_path = os.path.join(tmpdir, 'index.html')
        file_list = (entry for entry in web_util.list_url(cache_prefix) if (entry.endswith('.yaml') or entry.endswith('.key')))
        with open(index_html_path, 'w') as f:
            f.write(BUILD_CACHE_INDEX_TEMPLATE.format(title='Spack Package Index', path_list='\n'.join((BUILD_CACHE_INDEX_ENTRY_TEMPLATE.format(path=path) for path in file_list))))
        web_util.push_to_url(index_html_path, url_util.join(cache_prefix, 'index.html'), keep_original=False, extra_args={'ContentType': 'text/html'})
    finally:
        shutil.rmtree(tmpdir)