import_file_to_cache#

astropy.utils.data.import_file_to_cache(url_key, filename, remove_original=False, pkgname='astropy', *, replace=True)[source]#

Import the on-disk file specified by filename to the cache.

The provided url_key will be the name used in the cache. The file should contain the contents of this URL, at least notionally (the URL may be temporarily or permanently unavailable). It is using url_key that users will request these contents from the cache. See download_file() for details.

If url_key already exists in the cache, it will be updated to point to these imported contents, and its old contents will be deleted from the cache.

Parameters:
url_keystr

The key to index the file under. This should probably be the URL where the file was located, though if you obtained it from a mirror you should use the URL of the primary location.

filenamestr

The file whose contents you want to import.

remove_originalbool

Whether to remove the original file (filename) once import is complete.

pkgnamestr, optional

The package name to use to locate the download cache. i.e. for pkgname='astropy' the default cache location is ~/.astropy/cache.

replacebool, optional

Whether or not to replace an existing object in the cache, if one exists. If replacement is not requested but the object exists, silently pass.