eradiate.data.AssetManager¶
- class eradiate.data.AssetManager(cache_dir, unpack_dir, install_dir, base_uri, manifest=None, resource_aliases=NOTHING, installed=NOTHING)[source]¶
Bases:
objectLightweight package manager for Eradiate’s data files.
This class implements a basic package management system which can list, download, decompress and install resources that take the form of compressed archive files.
- Parameters:
- Fields:
Notes
By default, the unique asset manager instance
eradiate.asset_manageris initialized based on user-specified configuration:cache_dir⇒<settings["data_path"]>/cachedunpack_dir⇒<settings["data_path"]>/unpackedinstall_dir⇒<settings["data_path"]>/installed/eradiate-v<__version__>base_uri⇒settings["data_url"]
Examples
A single instance of the asset manager is available as
eradiate.asset_manager:>>> from eradiate import asset_manager >>> asset_manager.update() >>> asset_manager.install(["core", "panellus"])
- download(resource_ids, unpack=True, progressbar=True)[source]¶
Download a resource from remote storage to the cache directory.
- Parameters:
Notes
This function uses the
pooch.retrieve()function under the hood.
- info(show=False)[source]¶
Collect information about the asset manager.
- Parameters:
show (
bool) – IfTrue, display information to the terminal. Otherwise, return it as a dictionary.
- install(resource_ids, progressbar=True)[source]¶
Install a resource and make it available for consumption.
- list(what='resources')[source]¶
Display the list available resources in the manifest and their state.
- Parameters:
what (
{"resources", "aliases", "all"}) – One or several keywords that specify what to show.
- state(resource_ids)[source]¶
Return information about the state of one or several resources.
Each resource has the following possible states:
cached: the archive is downloaded and found in the cache directory;
unpacked: the archive is extracted to the unpack location;
installed: the resource is installed to the installation directory.
- update(download=None)[source]¶
Update the manifest, either reading it from disk if offline or recent enough, or downloading it from remote storage.
- Parameters:
download (
bool, optional) – IfTrue, download the manifest from remote storage first. IfFalse, only read from disk. IfNone(unset), apply default policy (download if the file on disk is more than a day old and not in offline mode).
- property installed_path¶
Path to the list of installed resources.
- property manifest_path¶
Path to the manifest file.