xmemcli 0.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
xmemcli/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """Standalone xmemcli package (``xmemcli`` console script)."""
2
+
3
+ __version__ = "0.0.1"
xmemcli/_envelope.py ADDED
@@ -0,0 +1,24 @@
1
+ """Batch API envelope helpers shared by stdlib-only CLI modules.
2
+
3
+ The HTTP API returns ``{"items": [...], "errors": [...]}`` on success paths too.
4
+ Callers must reject a non-empty ``errors`` array before reading ``items``.
5
+ """
6
+
7
+ from typing import Any
8
+
9
+
10
+ def batch_envelope_error(envelope: Any) -> str | None:
11
+ """Return the first API error message when the batch ``errors`` array is non-empty."""
12
+ if not isinstance(envelope, dict):
13
+ return "API returned non-object envelope"
14
+ errors = envelope.get("errors")
15
+ if not isinstance(errors, list) or not errors:
16
+ return None
17
+ first = errors[0]
18
+ if not isinstance(first, dict):
19
+ return "API error"
20
+ message = first.get("message")
21
+ if isinstance(message, str) and message:
22
+ return message
23
+ code = first.get("code")
24
+ return str(code) if code else "API error"