CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
y33-j3T

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: y33-j3T/Coursera-Deep-Learning
Path: blob/master/Convolutional Neural Networks/dummy/__pycache__/download.cpython-35.pyc
Views: 13377


��YU�@sXddlZddlZddlZddlZddlZdd�Zdd�ZdS)�NcCsDt||�|}dj|�}tjj|�tjj�dS)z}
    Function used for printing the download progress.
    Used as a call-back function in maybe_download_and_extract().
    z
- Download progress: {0:.1%}N)�float�format�sys�stdout�write�flush)�count�
block_size�
total_sizeZpct_complete�msg�r�/output/download.py�_print_download_progresssrcCs|jd�d}tjj||�}tjj|�s�tjj|�sYtj|�tjjd|d|dt	�\}}t
�t
d�|jd�r�tj
d|d	d
�j|�n.|jd�r�tjd
|d	d�j|�t
d�n
t
d�dS)a�
    Download and extract the data if it doesn't already exist.
    Assumes the url is a tar-ball file.
    :param url:
        Internet URL for the tar-file to download.
        Example: "https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz"
    :param download_dir:
        Directory where the downloaded file is saved.
        Example: "data/CIFAR-10/"
    :return:
        Nothing.
    �/��url�filename�
reporthookz$Download finished. Extracting files.z.zip�file�mode�r�.tar.gz�.tgz�namezr:gzzDone.z9Data has apparently already been downloaded and unpacked.N�����)rr)�split�os�path�join�exists�makedirs�urllib�request�urlretriever�print�endswith�zipfile�ZipFile�
extractall�tarfile�open)r�download_dirr�	file_path�_rrr
�maybe_download_and_extract0s 

"
r.)rr�urllib.requestr!r)r&rr.rrrr
�<module>s