INNER CODE UNIT · Python

_archive_if_requested

ythx-101/x-tweet-fetcher · src/xtf/cli.py:39

def _archive_if_requested(args, result: dict[str, Any], tweet_dicts) -> None:
    """Archive fetched tweet dicts when --ledger is set (never fatal).

    Without --ledger this is a no-op, keeping legacy behavior identical.
    """
    if not args.ledger:
        return
    if result.get("error") or not tweet_dicts:
        return
    db = Path(args.ledger).expanduser()
    try:
        report = archive_tweets(
            db, tweet_dicts, source=f"xtf:{result.get('backend', 'fetch')}"
        )
        result["ledger"] = report
    except Exception as exc:  # archiving must not break a successful fetch
        result["ledger_error"] = f"{type(exc).__name__}: {exc}"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…