MCPcopy Create free account
hub / github.com/jackvale/rectg / build_stats_table

Function build_stats_table

scripts/generate_readme.py:122–142  ·  view source on GitHub ↗

构建 README 顶部数据概览。

(type_counts: dict[str, int], category_count: int)

Source from the content-addressed store, hash-verified

120 return "<br>".join(links)
121
122def build_stats_table(type_counts: dict[str, int], category_count: int) -> str:
123 """构建 README 顶部数据概览。"""
124 total = sum(type_counts.values())
125 stat_items = [
126 ("总收录", format_count(total), "频道 / 群组 / 机器人"),
127 ("分类", format_count(category_count), "主题索引"),
128 ("频道", format_count(type_counts.get("channel", 0)), "Channel"),
129 ("群组", format_count(type_counts.get("group", 0)), "Group"),
130 ]
131 if type_counts.get("bot", 0) > 0:
132 stat_items.append(("机器人", format_count(type_counts.get("bot", 0)), "Bot"))
133
134 cells = []
135 for label, value, hint in stat_items:
136 cells.append(
137 " "
138 f'<td align="center"><strong>{html.escape(value)}</strong><br>'
139 f'<sub>{html.escape(label)} · {html.escape(hint)}</sub></td>'
140 )
141
142 return "\n".join(["<table>", " <tr>", *cells, " </tr>", "</table>"])
143
144def generate_readme(conn: sqlite3.Connection) -> str:
145 """从数据库生成 README.md 内容。"""

Callers 1

generate_readmeFunction · 0.85

Calls 1

format_countFunction · 0.85

Tested by

no test coverage detected