def download_and_extract(root: Path, info: DownloadInfo) -> None:
    """Download and extract a dataset.

    Args:
        root: Root directory where the dataset will be stored
        info: Download information for the dataset

    Raises:
        RuntimeError: If the URL scheme is not http(s)
    """
    root.mkdir(parents=True, exist_ok=True)

    # save the compressed file in the specified root directory
    downloaded_file_path = root / info.filename if info.filename else root / info.url.split("/")[-1]

    if downloaded_file_path.exists():
        logger.info("Existing dataset archive found. Skipping download stage.")
    else:
        logger.info("Downloading the %s dataset.", info.name)
        # audit url. allowing only http:// or https://
        if info.url.startswith("http://") or info.url.startswith("https://"):
            with DownloadProgressBar(unit="B", unit_scale=True, miniters=1, desc=info.name) as progress_bar:
                urlretrieve(  # noqa: S310  # nosec B310
                    url=f"{info.url}",
                    filename=downloaded_file_path,
                    reporthook=progress_bar.update_to,
                )
            logger.info("Checking the hash of the downloaded file.")
            check_hash(downloaded_file_path, info.hashsum)
        else:
            msg = f"Invalid URL to download dataset. Supported 'http://' or 'https://' but '{info.url}' is requested"
            raise RuntimeError(msg)

    extract(downloaded_file_path, root)
Download and extract a dataset.

    Args:
        root: Root directory where the dataset will be stored
        info: Download information for the dataset

    Raises:
        RuntimeError: If the URL scheme is not http(s)
    
src/anomalib/data/utils/download.py