diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2024-12-17 15:59:39 +0000 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2024-12-17 19:39:53 +0100 |
commit | 379ee839f9ae374302c4b9f444c9f804ec7a2796 (patch) | |
tree | 942e59a90fb3bc7ef4056035a7cf1ec2e01df9ad | |
parent | ba32e50a1b2103e9f548c30ef5e96375c0002372 (diff) | |
download | qemu-379ee839f9ae374302c4b9f444c9f804ec7a2796.zip qemu-379ee839f9ae374302c4b9f444c9f804ec7a2796.tar.gz qemu-379ee839f9ae374302c4b9f444c9f804ec7a2796.tar.bz2 |
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>
-rw-r--r-- | tests/functional/qemu_test/archive.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/functional/qemu_test/archive.py b/tests/functional/qemu_test/archive.py index 9872f08..06b6670 100644 --- a/tests/functional/qemu_test/archive.py +++ b/tests/functional/qemu_test/archive.py @@ -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) |