[llvm] r356884 - gn build: Let get.py keep zip file in memory instead of using a temp file
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 25 04:32:27 PDT 2019
Author: nico
Date: Mon Mar 25 04:32:27 2019
New Revision: 356884
URL: http://llvm.org/viewvc/llvm-project?rev=356884&view=rev
Log:
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
Modified:
llvm/trunk/utils/gn/get.py
Modified: llvm/trunk/utils/gn/get.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/get.py?rev=356884&r1=356883&r2=356884&view=diff
==============================================================================
--- llvm/trunk/utils/gn/get.py (original)
+++ llvm/trunk/utils/gn/get.py Mon Mar 25 04:32:27 2019
@@ -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."""
+def download_and_unpack(url, output_dir, gn):
+ """Download an archive from url and extract gn from it into output_dir."""
print('downloading %s ...' % url, end='')
sys.stdout.flush()
- output_file.write(urllib2.urlopen(url).read())
+ data = 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)
+ zipfile.ZipFile(io.BytesIO(data)).extract(gn, path=output_dir)
def set_executable_bit(path):
More information about the llvm-commits
mailing list