Renames src/fabledassistant -> src/scribe and all imports, plus the default DB name and DB user/password (fabled -> scribe) in config + compose. 952 refs / 154 files. Reverses the old 'internal name stays fabledassistant' convention. Code-only: live databases are still physically named 'fabledassistant'. Deployed environments must set POSTGRES_DB / POSTGRES_USER (or rename the DB) since the defaults now resolve to 'scribe'. Repo (FabledScribe), git host (fabledsword), MCP (fabled-git) and the image name (fabledscribe) are intentionally unchanged. ruff check src/ clean locally; CI (typecheck + pytest) is the gate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
25 lines
844 B
Python
25 lines
844 B
Python
from datetime import date
|
|
|
|
from quart import jsonify, request
|
|
|
|
|
|
def not_found(resource: str = "Item"):
|
|
return jsonify({"error": f"{resource} not found"}), 404
|
|
|
|
|
|
def parse_iso_date(value: str | None, field: str = "date"):
|
|
"""Parse an ISO date string. Returns a date, None, or a (response, 400) tuple."""
|
|
if not value:
|
|
return None
|
|
try:
|
|
return date.fromisoformat(value)
|
|
except ValueError:
|
|
return jsonify({"error": f"Invalid {field} format. Use YYYY-MM-DD."}), 400
|
|
|
|
|
|
def parse_pagination(default_limit: int = 50, max_limit: int = 500) -> tuple[int, int]:
|
|
"""Extract and clamp ``limit`` / ``offset`` from the current request's query string."""
|
|
limit = min(request.args.get("limit", default_limit, type=int), max_limit)
|
|
offset = request.args.get("offset", 0, type=int)
|
|
return limit, offset
|