def _get_download_or_cache(filename, data_home=None, url=SESAR_RRLYRAE_URL, force_download=False): """Private utility to download and/or load data from disk cache.""" if data_home is None: data_home = get_data_home(data_home) data_home = os.path.join(data_home, 'Sesar2010') if not os.path.exists(data_home): os.makedirs(data_home) src_url = SESAR_RRLYRAE_URL + filename save_loc = os.path.join(data_home, filename) if force_download or not os.path.exists(save_loc): buf = download_with_progress_bar(src_url) open(save_loc, 'wb').write(buf) return save_loc
def _get_download_or_cache(filename, data_home=None, url=SESAR_RRLYRAE_URL, force_download=False): """Private utility to download and/or load data from disk cache.""" # Import here so astroML is not required at package level from astroML.datasets.tools import get_data_home, download_with_progress_bar if data_home is None: data_home = get_data_home(data_home) data_home = os.path.join(data_home, "Sesar2010") if not os.path.exists(data_home): os.makedirs(data_home) src_url = SESAR_RRLYRAE_URL + filename save_loc = os.path.join(data_home, filename) if force_download or not os.path.exists(save_loc): buf = download_with_progress_bar(src_url) open(save_loc, "wb").write(buf) return save_loc
def _get_download_or_cache(filename, data_home=None, url=SESAR_RRLYRAE_URL, force_download=False): """Private utility to download and/or load data from disk cache.""" # Import here so astroML is not required at package level from astroML.datasets.tools import (get_data_home, download_with_progress_bar) if data_home is None: data_home = get_data_home(data_home) data_home = os.path.join(data_home, 'Sesar2010') if not os.path.exists(data_home): os.makedirs(data_home) src_url = SESAR_RRLYRAE_URL + filename save_loc = os.path.join(data_home, filename) if force_download or not os.path.exists(save_loc): buf = download_with_progress_bar(src_url) open(save_loc, 'wb').write(buf) return save_loc
def _get_download_or_cache(filename, data_home=None, url=SESAR_RRLYRAE_URL, force_download=False): """Private utility to download and/or load data from disk cache.""" # Import here so astroML is not required at package level from astroML.datasets.tools import get_data_home if data_home is None: data_home = get_data_home(data_home) data_home = os.path.join(data_home, 'Sesar2010') if not os.path.exists(data_home): os.makedirs(data_home) src_url = SESAR_RRLYRAE_URL + filename save_loc = os.path.join(data_home, filename) if force_download or not os.path.exists(save_loc): fhandle = urlopen(src_url) with open(save_loc, 'wb') as cache: cache.write(fhandle.read()) return save_loc