Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
path : str
Destination path of downloaded file.
r: requests.models.Response
URL response that can be used to get the data.
kind : str
Kind of file. Must be one of ALLOWED_FILE_TYPES.
verbose : bool
Whether to print verbose output while downloading files.
Returns
-------
None
"""
file_like_object = io.BytesIO(r.content)
if kind == "zip":
archive = zipfile.ZipFile(file_like_object)
if kind == "tar":
archive = tarfile.open(fileobj=file_like_object)
if kind == "tar.gz":
archive = tarfile.open(fileobj=file_like_object, mode="r:gz")
os.makedirs(path, exist_ok=True)
archive.extractall(path)
if verbose is True:
print("Extracted output to {}".format(path))