httk.core.fetching

Fetch URL sources through OPTIMADE or the registered file-reader pipeline.

Functions

fetch(url, *[, raw, timeout, kind])

Fetch a URL as an OPTIMADE entry or a registered file format.

Module Contents

httk.core.fetching.fetch(url, *, raw=False, timeout=None, kind=None, **kwargs)[source]

Fetch a URL as an OPTIMADE entry or a registered file format.

kind="optimade" forces OPTIMADE handling and kind="load" forces file-reader handling. With no kind, a reader-claimed extension wins over an OPTIMADE-shaped path; a reader-claimed basename is ambiguous and requires an explicit kind. file:// URLs are supported in either branch. Redirects follow urllib defaults.

As the explicit URL entry point, this function supplies the same network consent represented by DatastreamURL; it does not use implicit bare-string network access for the reader branch.

Parameters:
  • url (str) – URL to fetch.

  • raw (bool) – Whether to return a neutral payload without a format adapter.

  • timeout (float | None) – Optional timeout for URL-backed reader access or OPTIMADE requests.

  • kind (str | None) – Optional branch selector: "optimade" or "load".

  • **kwargs (Any) – Additional options passed to the file reader.

Returns:

The fetched OPTIMADE resource or loaded file value.

Raises:

ValueError – If the URL, kind, or automatic branch selection is invalid.

Return type:

Any