MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / __extract

Method __extract

src/commoncode/testcase.py:203–216  ·  view source on GitHub ↗

Given an archive file identified by test_path relative to a test files directory, return a new temp directory where the archive file has been extracted using extract_func. If `verbatim` is True preserve the permissions.

(self, test_path, extract_func=None, verbatim=False, filter=None)

Source from the content-addressed store, hash-verified

201 os.remove(tf)
202
203 def __extract(self, test_path, extract_func=None, verbatim=False, filter=None):
204 """
205 Given an archive file identified by test_path relative
206 to a test files directory, return a new temp directory where the
207 archive file has been extracted using extract_func.
208 If `verbatim` is True preserve the permissions.
209 """
210 assert test_path and test_path != ""
211 test_path = to_os_native_path(test_path)
212 target_path = path.basename(test_path)
213 target_dir = self.get_temp_dir(target_path)
214 original_archive = self.get_test_loc(test_path)
215 extract_func(original_archive, target_dir, verbatim=verbatim, filter=filter)
216 return target_dir
217
218 def extract_test_zip(self, test_path, *args, **kwargs):
219 return self.__extract(test_path, extract_zip)

Callers 5

extract_test_zipMethod · 0.95
extract_test_zip_rawMethod · 0.95
extract_test_tarMethod · 0.95
extract_test_tar_rawMethod · 0.95

Calls 3

get_temp_dirMethod · 0.95
get_test_locMethod · 0.95
to_os_native_pathFunction · 0.85

Tested by

no test coverage detected