def check_datafile_present_and_download(path, backup_url=None):
    """Check whether the file is present, otherwise download.
    """
    path = Path(path)
    if path.is_file(): return True
    if backup_url is None: return False
    logg.info('try downloading from url\n' + backup_url + '\n' +
              '... this may take a while but only happens once')
    if not path.parent.is_dir():
        logg.info('creating directory', str(path.parent) + '/', 'for saving data')
        path.parent.mkdir(parents=True)
    from urllib.request import urlretrieve
    urlretrieve(backup_url, str(path), reporthook=download_progress)
    logg.info('')
    return True
def check_datafile_present_and_download ( path , backup_url = None ) : path = Path ( path ) if path . is_file ( ) : return True if backup_url is None : return False logg . info ( 'try downloading from url\n' + backup_url + '\n' + '... this may take a while but only happens once' ) if not path . parent . is_dir ( ) : logg . info ( 'creating directory' , str ( path . parent ) + '/' , 'for saving data' ) path . parent . mkdir ( parents = True ) from urllib . request import urlretrieve urlretrieve ( backup_url , str ( path ) , reporthook = download_progress ) logg . info ( '' ) return True
Check whether the file is present, otherwise download.