vimsheet.fetch.fetch_worker

Low-level HTTP fetch helpers — no Textual or VimSheet model imports.

class vimsheet.fetch.fetch_worker.FetchResult(raw: 'bytes | None', status_code: 'int | None', error: 'str | None')[source]

Bases: object

Parameters:
  • raw (bytes | None)

  • status_code (int | None)

  • error (str | None)

raw: bytes | None
status_code: int | None
error: str | None
property ok: bool
__init__(raw, status_code, error)
Parameters:
  • raw (bytes | None)

  • status_code (int | None)

  • error (str | None)

Return type:

None

vimsheet.fetch.fetch_worker.parse_curl_command(cmd)[source]

Parse a curl command string into url, headers, and method.

Parameters:

cmd (str) –

A command that starts with curl, e.g.:

curl -H "Authorization: Bearer $TOKEN" https://api.example.com/data

Returns:

  • dict{"url": ..., "headers": {"Key": "Value", ...}, "method": "GET"}

  • Environment variables (``$VAR``, :py:class:`$```{VAR}:py:class:``) are resolved from

  • os.environ before parsing.

Return type:

dict[str, Any]

vimsheet.fetch.fetch_worker.do_fetch(url, timeout=10.0, headers=None, method='GET')[source]

Blocking HTTP request. Tries requests first, falls back to urllib.

Parameters:
Return type:

FetchResult

vimsheet.fetch.fetch_worker.parse_response(result)[source]

Parse a successful FetchResult into a Python object.

Tries JSON first; returns the raw text string on JSON parse failure.

Parameters:

result (FetchResult)

Return type:

Any

vimsheet.fetch.fetch_worker.extract_json_path(data, path)[source]

Traverse data using dot-and-bracket notation.

Examples

“” → data unchanged “price” → data[“price”] “data.price” → data[“data”][“price”] “items[0].name” → data[“items”][0][“name”]

Raises KeyError / IndexError / TypeError on invalid paths.

Parameters:
Return type:

Any