import_file_to_cache(url_key, filename, hexdigest=None, remove_original=False, pkgname='astropy')¶
Import the on-disk file specified by filename to the cache.
url_keywill 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_keythat users will request these contents from the cache. See
url_keyalready exists in the cache, it will be updated to point to these imported contents, and its old contents will be deleted from the cache if nothing else points there.
If a file already exists in the cache with the same contents (no matter the
url_key), its modification time will be updated but this file will not be copied/moved over it.
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.
The file whose contents you want to import.
- hexdigeststr, optional
The cryptographic hash of the file, as computed by
compute_hash. If it is not provided,
compute_hashwill be called. This argument is available in case it is easier to compute the hash progressively as the file is downloaded.
Whether to remove the original file (
filename) once import is complete. If the original is to be removed, and if the cache lives on the same filesystem as the file to be imported, a simple rename operation will move the file into the cache. Otherwise the file will be copied and then the original deleted if appropriate.
The package name to use to locate the download cache. i.e. for
pkgname='astropy'the default cache location is