1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

gn build: Let get.py keep zip file in memory instead of using a temp file

The zip is small, and it's a bit less code this way.
No intended behavior change.

Differential Revision: https://reviews.llvm.org/D59677

llvm-svn: 356884
This commit is contained in:
Nico Weber 2019-03-25 11:32:27 +00:00
parent fb2328ba27
commit 0a60122796

View File

@ -3,27 +3,20 @@
from __future__ import print_function
import io
import os
import urllib2
import sys
import tempfile
import zipfile
def download_url(url, output_file):
"""Download url into output_file."""
print('downloading %s ...' % url, end='')
sys.stdout.flush()
output_file.write(urllib2.urlopen(url).read())
print(' done')
def download_and_unpack(url, output_dir, gn):
"""Download an archive from url and extract gn from it into output_dir."""
with tempfile.TemporaryFile() as f:
download_url(url, f)
f.seek(0)
zipfile.ZipFile(f).extract(gn, path=output_dir)
print('downloading %s ...' % url, end='')
sys.stdout.flush()
data = urllib2.urlopen(url).read()
print(' done')
zipfile.ZipFile(io.BytesIO(data)).extract(gn, path=output_dir)
def set_executable_bit(path):