This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
| title | author | role | date | parent | wiki | public |
|---|---|---|---|---|---|---|
| Smartup Toolbox Minimum Ledger Script Template) | robbert | 4_1_1 | 2025-10-21 | 2_workplace | 2_workplace | false |
Smartup Toolbox Minimum Ledger Script Template)
python #!/usr/bin/env python3 """ Smartup Toolbox Minimum Ledger Script Template (v2.4)
Use this skeleton for any operation that reads/writes Forgejo CSV ledger files. Implements:
- single source environment (import from config)
- read via fetch_csv/fetch_csv_raw
- append/update via Forgejo API (write_with_retry/append_csv_row)
- QUOTE_ALL / legacy column consistency handled by forgejo_api """
import sys, os, json from datetime import datetime, timezone from pathlib import Path sys.path.append(str(Path(file).resolve().parent.parent / "common")) import forgejo_api as api import config # single source configuration
── Utility helpers ──────────────────────────────────────────
def iso_now() -> str: return datetime.now(timezone.utc).isoformat().replace("+00:00","Z")
── Example operation (read + append) ─────────────────────────
def sample_append(actor: str, description: str): """Example: append one event to master‑events.""" event = { "timestamp": iso_now(), "smartup_id": "0", "actor": actor, "script": Path(file).name, "event_type": "TEST_APPEND", "ref_file": "currency-ledger/example.csv", "description": description }
api.append_csv_row(
repo=config.LEDGER_REPO,
path="currency-ledger/master-events.csv",
new_row=event,
commit_msg=f"[actor={actor}][script={Path(__file__).name}] demo append",
actor=actor,
branch=config.LEDGER_BRANCH
)
print("✅ event logged to Forgejo ledger.")
── Main entrypoint ──────────────────────────────────────────
if name == "main": actor = os.getenv("SMARTUP_ACTOR", input("Actor alias > ")).strip() sample_append(actor, "Demonstrating standardized Forgejo write flow")