pysap.data
pysap.data#
A module that privides the utility functions to download toy datasets.
- get_sample_data(dataset_name, datadir='/home/cg260486/.local/share/pysap', verbose=1)[source]#
Get a sample dataset.
This function download the requested dataset in the ‘$HOME/.local/share/pysap’ directory.
- class ResumeURLOpener[source]#
Bases:
urllib.request.FancyURLopener
Create sub-class in order to overide error 206. This error means a partial file is being sent, which is fine in this case. Do nothing with this error.
Note: This was adapted from: http://code.activestate.com/recipes/83208-resuming-download-of-a-file/
- download_file(url, data_dir, resume=True, overwrite=False, verbose=0)[source]#
Load requested file if needed or requested.
- Parameters
url (str) – the url of the file to be downloaded.
data_dir (str) – path of the data directory.
resume (bool (optional, default True)) – if True, try to resume partially downloaded files
overwrite (bool (optional, default False)) – if True and file already exists, delete it.
verbose (int (optional, default 0)) – control the verbosity level.
- Returns
absolute path to the downloaded file.
- Return type
Notes
If, for any reason, the download procedure fails, all downloaded files are removed.