Skip to content

Commit f19efec

Browse files
committed
avocado/utils/archive.py: make probe function for zstd public
There's value in making the zstd probe function public (which was previously not perceived). This function can be used to skip/cancel tests when a suitable zstd is not found. Signed-off-by: Cleber Rosa <[email protected]>
1 parent 6c02201 commit f19efec

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

avocado/utils/archive.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ def is_zstd_file(path):
116116
return zstd_file.read(len(ZSTD_MAGIC)) == ZSTD_MAGIC
117117

118118

119-
def _probe_zstd_cmd():
119+
def probe_zstd_cmd():
120+
"""
121+
Attempts to find a suitable zstd tool that behaves as expected
122+
123+
:rtype: str or None
124+
:returns: path to a suitable zstd executable or None if not found
125+
"""
120126
zstd_cmd = shutil.which("zstd")
121127
if zstd_cmd is not None:
122128
proc = subprocess.run(
@@ -136,7 +142,7 @@ def zstd_uncompress(path, output_path=None, force=False):
136142
"""
137143
Extracts a zstd compressed file.
138144
"""
139-
zstd_cmd = _probe_zstd_cmd()
145+
zstd_cmd = probe_zstd_cmd()
140146
if not zstd_cmd:
141147
raise ArchiveException("Unable to find a suitable zstd compression tool")
142148
output_path = _decide_on_path(path, ".zst", output_path)

selftests/unit/utils/archive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from avocado.utils import archive, crypto, data_factory
88
from selftests.utils import BASEDIR, temp_dir_prefix
99

10-
ZSTD_AVAILABLE = archive._probe_zstd_cmd() is not None
10+
ZSTD_AVAILABLE = archive.probe_zstd_cmd() is not None
1111

1212

1313
class ArchiveTest(unittest.TestCase):

0 commit comments

Comments
 (0)