MCPcopy Index your code
hub / github.com/Codeplain-ai/codeplain / _display_status_message

Function _display_status_message

cli_output/status.py:79–110  ·  view source on GitHub ↗

Display appropriate status message based on credit state.

(plan_credits: Optional[dict], purchased_credits: list, promo_credits: list)

Source from the content-addressed store, hash-verified

77
78
79def _display_status_message(plan_credits: Optional[dict], purchased_credits: list, promo_credits: list) -> None:
80 """Display appropriate status message based on credit state."""
81 has_remaining = False
82
83 # Check if plan credits have remaining balance and are not expired
84 if plan_credits:
85 remaining = plan_credits["remaining"]
86 dt_str = plan_credits["period_end"].replace("Z", "+00:00")
87 period_end = datetime.fromisoformat(dt_str)
88 # If naive datetime, assume UTC
89 if period_end.tzinfo is None:
90 period_end = period_end.replace(tzinfo=timezone.utc)
91 now = datetime.now(timezone.utc)
92
93 if remaining > 0 and period_end > now:
94 has_remaining = True
95
96 # Check if any purchased or promo credits have remaining balance and not expired
97 for bucket in [*purchased_credits, *promo_credits]:
98 dt_str = bucket["expiry_date"].replace("Z", "+00:00")
99 expiry_date = datetime.fromisoformat(dt_str)
100 # If naive datetime, assume UTC
101 if expiry_date.tzinfo is None:
102 expiry_date = expiry_date.replace(tzinfo=timezone.utc)
103 now = datetime.now(timezone.utc)
104
105 if bucket["remaining"] > 0 and expiry_date > now:
106 has_remaining = True
107 break
108
109 if not has_remaining:
110 console.print("\nNo rendering credits remaining. Upgrade to continue rendering.")
111
112
113def print_status(api_key: str, api_url: str, client_version: str) -> None:

Calls

no outgoing calls