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-36.pyc
Views: 13377
3

��YU�@s<ddlZddlZddlZddlZddlZdd�Zdd�ZdS)�NcCs4t||�|}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�$/home/jovyan/work/Resnet/download.py�_print_download_progresss
rcCs�|jd�d}tjj||�}tjj|�s�tjj|�s>tj|�tjj||t	d�\}}t
�t
d�|jd�r�tj
|dd�j|�n|jd�r�tj|d
d�j|�t
d�nt
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�r)�file�mode�.tar.gz�.tgzzr:gz)�namerzDone.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