mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
tests/functional: add common zip_extract helper
This mirrors the existing archive_extract and cpio_extract helpers Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20241217155953.3950506-19-berrange@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
ba32e50a1b
commit
379ee839f9
1 changed files with 8 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
import os
|
||||
import subprocess
|
||||
import tarfile
|
||||
import zipfile
|
||||
|
||||
|
||||
def tar_extract(archive, dest_dir, member=None):
|
||||
|
@ -29,3 +30,10 @@ def cpio_extract(cpio_handle, output_path):
|
|||
input=cpio_handle.read(),
|
||||
stderr=subprocess.DEVNULL)
|
||||
os.chdir(cwd)
|
||||
|
||||
def zip_extract(archive, dest_dir, member=None):
|
||||
with zipfile.ZipFile(archive, 'r') as zf:
|
||||
if member:
|
||||
zf.extract(member=member, path=dest_dir)
|
||||
else:
|
||||
zf.extractall(path=dest_dir)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue