zstd#

Zstd interface for repodata.

Classes#

ZstdRepoInterface

Helper class that provides a standard way to create an ABC using

Functions#

withext(url, ext)

Change file extension in URL.

timeme(message)

Context manager for timing operations.

build_headers(json_path, state)

Build caching headers for a path and state.

download_repodata(url, json_path, session, state[, ...])

Download url to dest_path, optionally decompressing zstd.

_is_http_error_most_400_codes(→ bool)

Determine if HTTP error is a 4xx error (except 416).

request_url_zstd_state(→ dict | None)

Download .json.zst file and return parsed JSON.

withext(url, ext)#

Change file extension in URL.

timeme(message)#

Context manager for timing operations.

build_headers(json_path: pathlib.Path, state: conda.gateways.repodata.RepodataState)#

Build caching headers for a path and state.

download_repodata(url, json_path: pathlib.Path, session: conda.gateways.connection.Session, state: conda.gateways.repodata.RepodataState | None, is_zst=False, dest_path: pathlib.Path | None = None)#

Download url to dest_path, optionally decompressing zstd.

json_path: Path of old cached data (ignore etag if not exists). dest_path: Path to write new data.

_is_http_error_most_400_codes(e: requests.HTTPError) bool#

Determine if HTTP error is a 4xx error (except 416).

exception ZstSkip#

Bases: Exception

Exception to skip zst format check.

Initialize self. See help(type(self)) for accurate signature.

request_url_zstd_state(url, state: conda.gateways.repodata.RepodataState, *, session: conda.gateways.connection.Session, cache: conda.gateways.repodata.RepodataCache, temp_path: pathlib.Path) dict | None#

Download .json.zst file and return parsed JSON.

Parameters:
  • url -- URL to download from

  • state -- Repodata state

  • session -- Session object

  • cache -- Repodata cache

  • temp_path -- Temporary path to write json to

Returns:

Parsed JSON or None if error

Return type:

dict | None

class ZstdRepoInterface(url: str, repodata_fn: str | None, *, cache: conda.gateways.repodata.RepodataCache, **kwargs)#

Bases: conda.gateways.repodata.RepoInterface

Helper class that provides a standard way to create an ABC using inheritance.

repodata(state: dict | conda.gateways.repodata.RepodataState) str | None#

Fetch newest repodata if necessary.

Always writes to cache_path_json.

repodata_parsed(state: dict | conda.gateways.repodata.RepodataState) dict | None#

Use this to avoid a redundant parse when repodata is updated.

When repodata is not updated, it doesn't matter whether this function or the caller reads from a file.

_repodata_state_copy(state: dict | conda.gateways.repodata.RepodataState) conda.gateways.repodata.RepodataState#

Create a copy of state to avoid modifying the caller's dict.