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

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 04:31:21 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL356884: gn build: Let get.py keep zip file in memory instead of using a temp file (authored by nico, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59677?vs=191804&id=192075#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59677/new/

https://reviews.llvm.org/D59677

Files:
  llvm/trunk/utils/gn/get.py


Index: llvm/trunk/utils/gn/get.py
===================================================================
--- llvm/trunk/utils/gn/get.py
+++ llvm/trunk/utils/gn/get.py
@@ -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):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59677.192075.patch
Type: text/x-patch
Size: 1082 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190325/0877c345/attachment.bin>


More information about the llvm-commits mailing list