PyLimeRPC 0.2.0 — prompts.md Prompt 1-4

- responses.py: get_summary() (raw RPC get_summary), count_responses() ->
  frozen ResponseCounts(completed, incomplete, total), export_responses_auto()
  with automatic format fallback (xlsx -> xls -> csv) on IWriter errors
- utils.py: summary_counts_full() -> (completed, incomplete, total) with
  per-LS-version key fallbacks; summary_counts left untouched
- surveys.py: get_survey_by_sid() (dict | None), get_survey_info() ->
  frozen SurveyInfo(sid, title, active)
- tokens.py: documented that extra/custom token attributes (attribute_1, ...)
  pass through unchanged in add_participants/list_participants
- LsClient: get_summary, count_responses, get_survey_by_sid, get_survey_info,
  export_responses_auto; __all__ + re-exports updated
- README: new "Response counts & summary" section + usage examples
- .gitignore: prompts.md added (local-only docs, like werkdocument.md)
- version 0.1.0 -> 0.2.0 (__init__.py + pyproject.toml)
- tests: +27 FakeRpc unit tests (96 passed, 2 deselected)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-20 11:56:03 +01:00
commit 6822eab467

View file

@ -16,8 +16,8 @@ Modules:
config — settings from .env / environment variables (LsConfig)
rpc — JSON-RPC transport (rpc_call, RpcClient, endpoint_url)
session — session keys: get_session_key / release_session_key
surveys — list_surveys, get_survey_properties, filter_active
responses — export_responses (CSV/JSON), export_statistics
surveys — list_surveys, get_survey_properties, get_survey_by_sid, get_survey_info, filter_active
responses — export_responses (CSV/JSON), export_responses_auto, export_statistics, get_summary, count_responses
tokens — token management (participants): add / list / delete
errors — custom exceptions (LsError, LsConnectionError, LsApiError, LsAuthError)
utils — small shared helpers
@ -38,15 +38,29 @@ from . import surveys as _surveys
from . import tokens as _tokens
from .config import LsConfig
from .errors import LsApiError, LsAuthError, LsConnectionError, LsError
from .responses import export_responses, export_statistics
from .responses import (
ResponseCounts,
count_responses,
export_responses,
export_responses_auto,
export_statistics,
get_summary,
)
from .rpc import RpcClient, endpoint_url, rpc_call
from .session import get_session_key, release_session_key
from .surveys import filter_active, get_survey_properties, list_surveys
from .surveys import (
SurveyInfo,
filter_active,
get_survey_by_sid,
get_survey_info,
get_survey_properties,
list_surveys,
)
from .tokens import add_participants, delete_participants, list_participants
logger = logging.getLogger(__name__)
__version__ = "0.1.0"
__version__ = "0.2.0"
class LsClient:
@ -123,6 +137,25 @@ class LsClient:
"""Properties of a single survey (see ``surveys.get_survey_properties``)."""
return _surveys.get_survey_properties(self.rpc, self._require_key(), sid, properties=properties)
def get_survey_by_sid(
self,
sid: int | str,
owner_id: int | str | None = None,
group_id: int | str | None = None,
) -> dict[str, Any] | None:
"""Find one survey by sid (see ``surveys.get_survey_by_sid``); ``None`` if it does not exist."""
return _surveys.get_survey_by_sid(
self.rpc,
self._require_key(),
sid,
owner_id=owner_id if owner_id is not None else self.config.owner_id,
group_id=group_id if group_id is not None else self.config.group_id,
)
def get_survey_info(self, sid: int | str) -> SurveyInfo | None:
"""Compact info (sid/title/active) of a survey (see ``surveys.get_survey_info``)."""
return _surveys.get_survey_info(self.rpc, self._require_key(), sid)
# -- responses / statistics ---------------------------------------
def export_responses(
@ -134,6 +167,18 @@ class LsClient:
"""Export responses of a survey (see ``responses.export_responses``)."""
return _responses.export_responses(self.rpc, self._require_key(), sid, doc_type, **kwargs)
def export_responses_auto(
self,
sid: int | str,
formats: Iterable[str] = ("xlsx", "xls", "csv"),
**kwargs: Any,
) -> tuple[bytes | Path, str]:
"""Export responses with automatic format fallback (see ``responses.export_responses_auto``).
Returns ``(data, used_format)``.
"""
return _responses.export_responses_auto(self.rpc, self._require_key(), sid, formats, **kwargs)
def export_statistics(
self,
sid: int | str,
@ -143,6 +188,16 @@ class LsClient:
"""Export statistics of a survey (see ``responses.export_statistics``)."""
return _responses.export_statistics(self.rpc, self._require_key(), sid, doc_type, **kwargs)
# -- summary / response-tellingen -----------------------------------
def get_summary(self, sid: int | str) -> dict[str, Any]:
"""Raw ``get_summary`` result of a survey (see ``responses.get_summary``)."""
return _responses.get_summary(self.rpc, self._require_key(), sid)
def count_responses(self, sid: int | str) -> ResponseCounts:
"""Response counts (completed/incomplete/total) of a survey (see ``responses.count_responses``)."""
return _responses.count_responses(self.rpc, self._require_key(), sid)
# -- tokens (participants) ------------------------------------------
def add_participants(
@ -177,9 +232,16 @@ __all__ = [
"release_session_key",
"list_surveys",
"get_survey_properties",
"get_survey_by_sid",
"get_survey_info",
"SurveyInfo",
"filter_active",
"export_responses",
"export_responses_auto",
"export_statistics",
"get_summary",
"count_responses",
"ResponseCounts",
"add_participants",
"list_participants",
"delete_participants",