repodata#
Repodata interface.
Classes#
Channel: |
|
Helper class that provides a standard way to create an ABC using |
|
Provides an interface for retrieving repodata data from channels. |
|
Load/save info file that accompanies cached repodata.json. |
|
Handle caching for a single repodata.json + repodata.info.json |
|
Combine RepodataCache and RepoInterface to provide subdir_data.SubdirData() |
Functions#
|
|
|
|
|
Function that determines the correct Session object to be returned |
|
|
|
|
|
|
|
|
|
Use in a with: statement to translate requests exceptions to conda ones. |
|
|
|
|
|
|
Attributes#
- exception CondaError(message: str | None, caused_by: Any = None, **kwargs)#
Bases:
ExceptionCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- stringify(obj, content_max_len=0)#
- CONDA_HOMEPAGE_URL: Final = 'https://conda.io'#
- REPODATA_FN: Final = 'repodata.json'#
- context#
- join_url#
- class PackageCacheData(pkgs_dir)#
- property _package_cache_records#
- property is_writable#
- _cache_: dict[str, PackageCacheData]#
- insert(package_cache_record)#
- load()#
- reload()#
- get(package_ref: conda.models.records.PackageRecord, default=NULL)#
- remove(package_ref, default=NULL)#
- query(package_ref_or_match_spec)#
- iter_records()#
- classmethod query_all(package_ref_or_match_spec, pkgs_dirs=None)#
- classmethod first_writable(pkgs_dirs=None)#
- classmethod writable_caches(pkgs_dirs=None)#
- classmethod read_only_caches(pkgs_dirs=None)#
- classmethod all_caches_writable_first(pkgs_dirs=None)#
- classmethod get_all_extracted_entries()#
- classmethod get_entry_to_link(package_ref)#
- classmethod tarball_file_in_cache(tarball_path, md5sum=None, exclude_caches=())#
- classmethod clear()#
- tarball_file_in_this_cache(tarball_path, md5sum=None)#
- _check_writable()#
- static _clean_tarball_path_and_get_md5sum(tarball_path, md5sum=None)#
- _scan_for_dist_no_channel(dist_str)#
- itervalues()#
- values()#
- __repr__()#
Return repr(self).
- _make_single_record(package_filename)#
- static _dedupe_pkgs_dir_contents(pkgs_dir_contents)#
- exception CondaDependencyError(message: str)#
Bases:
conda.CondaErrorCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- exception CondaHTTPError(message: str, url: str, status_code: int | str, reason: str, elapsed_time: datetime.timedelta | str, response: requests.Response | None = None, caused_by: Any = None)#
Bases:
conda.CondaErrorCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- exception CondaSSLError(message: str | None, caused_by: Any | None = None, **kwargs)#
Bases:
conda.CondaErrorCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- exception NotWritableError(path: conda.common.path.PathType, errno: int, **kwargs)#
Bases:
conda.CondaError,OSErrorCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- exception ProxyError(message: str | None = None)#
Bases:
conda.CondaErrorCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
Bases:
ChannelErrorCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- class Channel(scheme: str | None = None, auth: str | None = None, location: str | None = None, token: str | None = None, name: str | None = None, platform: str | None = None, package_filename: str | None = None)#
Channel: scheme <> auth <> location <> token <> channel <> subchannel <> platform <> package_filename
Package Spec: channel <> subchannel <> namespace <> package_name
- _cache_#
- static from_value(value: str | None) Channel#
Construct a new
Channelfrom a single value.- Parameters:
value --
Anyone of the following forms:
- None, or one of the special strings "<unknown>", "None:///<unknown>", or "None":
represents the unknown channel, used for packages with unknown origin.
- A URL including a scheme like
file://orhttps://: represents a channel URL.
- A local directory path:
represents a local channel; relative paths must start with
./.- A package file (i.e. the path to a file ending in
.condaor.tar.bz2): represents a channel for a single package
- A known channel name:
represents a known channel, e.g. from the users
.condarcfile or the global configuration.
- Returns:
A channel object.
- static make_simple_channel(channel_alias: Channel, channel_url: str, name: str | None = None) Channel#
- urls(with_credentials: bool = False, subdirs: collections.abc.Iterable[str] | None = None) list[str]#
Generate URLs for this channel across specified platforms.
- Parameters:
with_credentials -- If True, include authentication credentials (token, auth) in URLs.
subdirs -- Specific platform subdirs to generate URLs for. If None, uses the channel's platform (if defined) or falls back to context.subdirs. If this is explicitly provided, overrides any platform defined in the channel.
Examples
>>> channel = Channel("conda-forge") >>> channel.urls() # Uses context.subdirs ['https://conda.anaconda.org/conda-forge/linux-64', 'https://conda.anaconda.org/conda-forge/noarch']
>>> channel = Channel("conda-forge/linux-aarch64") >>> channel.urls() # Uses channel's platform ['https://conda.anaconda.org/conda-forge/linux-aarch64', 'https://conda.anaconda.org/conda-forge/noarch']
>>> channel.urls(subdirs=("osx-64", "noarch")) ['https://conda.anaconda.org/conda-forge/osx-64', 'https://conda.anaconda.org/conda-forge/noarch']
- get_session(url: str)#
Function that determines the correct Session object to be returned based on the URL that is passed in.
- mkdir_p_sudo_safe(path)#
- lock(fd, *, lock_attempts=LOCK_ATTEMPTS)#
- stderrlog#
- CHECK_ALTERNATE_FORMAT_INTERVAL#
- LAST_MODIFIED_KEY = 'mod'#
- ETAG_KEY = 'etag'#
- CACHE_CONTROL_KEY = 'cache_control'#
- URL_KEY = 'url'#
- CACHE_STATE_SUFFIX = '.info.json'#
- ERROR_SNIPPET_LENGTH = 32#
- exception RepodataIsEmpty(channel: conda.models.channel.Channel | str, status_code: str | int, response: requests.models.Response | None = None)#
Bases:
conda.exceptions.UnavailableInvalidChannelSubclass used to determine when empty repodata should be cached, e.g. for a channel that doesn't provide current_repodata.json
Initialize self. See help(type(self)) for accurate signature.
- exception RepodataOnDisk#
Bases:
ExceptionIndicate that RepoInterface.repodata() successfully wrote repodata to disk, instead of returning a string.
Initialize self. See help(type(self)) for accurate signature.
- class RepoInterface#
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- exception Response304ContentUnchanged#
Bases:
ExceptionCommon base class for all non-exit exceptions.
Initialize self. See help(type(self)) for accurate signature.
- get_repo_interface() type[RepoInterface]#
- class CondaRepoInterface(url: str, repodata_fn: str | None, **kwargs)#
Bases:
RepoInterfaceProvides an interface for retrieving repodata data from channels.
- repodata(state: RepodataState) str | None#
Given a mutable state dictionary with information about the cache, return repodata.json (or current_repodata.json) as a str. This function also updates state, which is expected to be saved by the caller.
- _add_http_value_to_dict(resp, http_key, d, dict_key)#
- conda_http_errors(url, repodata_fn)#
Use in a with: statement to translate requests exceptions to conda ones.
- class RepodataState(cache_path_json: pathlib.Path | str = '', cache_path_state: pathlib.Path | str = '', repodata_fn='', dict=None)#
Bases:
collections.UserDictLoad/save info file that accompanies cached repodata.json.
- _aliased#
- _strings#
- class RepodataCache(base, repodata_fn)#
Handle caching for a single repodata.json + repodata.info.json (<hex-string>*.json inside dir)
Avoid race conditions while loading, saving repodata.json and cache state.
Also support bytes as in repodata_shards.msgpack.zst
base: directory and filename prefix for cache, e.g. /cache/dir/abc123; writes /cache/dir/abc123.json
- property cache_path_json#
- property cache_path_shards#
- property cache_path_state#
Out-of-band etag and other state needed by the RepoInterface.
- load_state(binary=False)#
Update self.state without reading repodata.
Return self.state.
- replace(temp_path: pathlib.Path, target=None)#
Rename path onto <repodata> path, synchronize state.
Relies on path's mtime not changing on move. temp_path should be adjacent to self.cache_path_json to be on the same filesystem.
- refresh(refresh_ns=0)#
Update access time in cache info file to indicate a HTTP 304 Not Modified response.
- lock(mode='a+')#
Lock .info.json file. Hold lock while modifying related files.
mode: "a+" then seek(0) to write/create; "r+" to read.
- stale()#
Compare state refresh_ns against cache control header and context.local_repodata_ttl.
- timeout()#
Return number of seconds until cache times out (<= 0 if already timed out).
- class RepodataFetch(cache_path_base: pathlib.Path, channel: conda.models.channel.Channel, repodata_fn: str, *, repo_interface_cls)#
Combine RepodataCache and RepoInterface to provide subdir_data.SubdirData() with what it needs.
Provide a variety of formats since some
RepoInterfacehave tojson.loads(...)anyway, and some clients don't need the Python data structure at all.- property url_w_repodata_fn#
- property cache_path_json#
- property cache_path_state#
Out-of-band etag and other state needed by the RepoInterface.
- property repo_cache: RepodataCache#
- property _repo: RepoInterface#
Changes as we mutate self.repodata_fn.
- cache_path_base: pathlib.Path#
- channel: conda.models.channel.Channel#
- repo_interface_cls: Any#
- fetch_latest_parsed() tuple[dict, RepodataState]#
Retrieve parsed latest or latest-cached repodata as a dict; update cache.
- Returns:
(repodata contents, state including cache headers)
- fetch_latest_path() tuple[pathlib.Path, RepodataState]#
Retrieve latest or latest-cached repodata; update cache.
- Returns:
(pathlib.Path to uncompressed repodata contents, RepodataState)
- fetch_latest() tuple[dict | str, RepodataState]#
Return up-to-date repodata and cache information. Fetch repodata from remote if cache has expired; return cached data if cache has not expired; return stale cached data or dummy data if in offline mode.
- read_cache() tuple[str, RepodataState]#
Read repodata from disk, without trying to fetch a fresh version.
- _md5_not_for_security(data)#
- cache_fn_url(url, repodata_fn=REPODATA_FN)#
- create_cache_dir()#