def write_artifact(artifact, outdir):
    # Reads artifact data from git and writes a zip file (and companion files) to `outdir`
    with utils.tempdir() as unpack_dir:
        with zipfile.ZipFile(artifact.location, 'r') as zf:
            zf.extractall(unpack_dir)

        with utils.tempdir() as package_dir:
            pack_artifact(artifact, os.path.join(unpack_dir, artifact.addon_id), package_dir)
            delete_companion_files(outdir)
            copy_tree(package_dir, outdir)
Example #2
0
def write_artifact(artifact, outdir):
    """ Reads artifact data from git and writes a zip file (and companion files) to `outdir` """
    repo = git.Repo(artifact.git_repo)
    with utils.tempdir() as unpack_dir:
        buffer = BytesIO()
        repo.archive(buffer, artifact.treeish, format="zip")
        with zipfile.ZipFile(buffer, 'r') as zf:
            zf.extractall(unpack_dir)

        with utils.tempdir() as package_dir:
            pack_artifact(artifact, unpack_dir, package_dir)
            delete_companion_files(outdir)
            copy_tree(package_dir, outdir)