releasetools: Don't return ZipFile from common.UnzipTemp().

In addition to the unzipping work, common.UnzipTemp() kindly bundles an
open ZipFile object as part of the return value. It doesn't look very
helpful to the callers though. It also looks less obvious that the
caller needs to properly close the handle (missing the close here is
benign though). This CL just removes the ZipFile object out of the
return value, and leaves the work to callers.

Test: `m dist` on both of A/B and non-A/B target.
Test: python -m unittest test_add_img_to_target_files
Test: python -m unittest test_common
Test: python -m unittest test_ota_from_target_files
Test: Check the callers to common.UnzipTemp() in code search.
Change-Id: Id47da3fd42a0e76d6ae8851f05780db319ee48cf
This commit is contained in:
Tao Bao
2018-01-09 13:21:02 -08:00
parent 01670eb141
commit dba59eeabd
7 changed files with 54 additions and 58 deletions

View File

@@ -584,8 +584,7 @@ def UnzipTemp(filename, pattern=None):
then unzip bar.zip into that_dir/BOOTABLE_IMAGES.
Returns:
(tempdir, zipobj): tempdir is the name of the temprary directory; zipobj is
a zipfile.ZipFile (of the main file), open for reading.
The name of the temporary directory.
"""
def unzip_to_dir(filename, dirname):
@@ -607,7 +606,7 @@ def UnzipTemp(filename, pattern=None):
else:
unzip_to_dir(filename, tmp)
return tmp, zipfile.ZipFile(filename, "r")
return tmp
def GetSparseImage(which, tmpdir, input_zip, allow_shared_blocks):