MCPcopy Create free account
hub / github.com/C3ting/ARL / dict2table

Function dict2table

app/utils/push.py:277–308  ·  view source on GitHub ↗
(info_list)

Source from the content-addressed store, hash-verified

275
276
277def dict2table(info_list):
278 if not info_list:
279 return ""
280 html = ""
281 table_style = 'style="border-collapse: collapse;"'
282 table_start = '<table {}>\n'.format(table_style)
283 table_end = '</table>\n'
284 style = 'style="border: 0.5pt solid windowtext;"'
285 thead_start = '<thead><tr><th {}>序号</th><th {}>\n'.format(style, style)
286 thead_end = '\n</th></tr></thead>'
287 th_join_tpl = '</th>\n<th {}>'.format(style)
288 thead_tpl = th_join_tpl.join(map(str, info_list[0].keys()))
289 html += table_start
290 html += thead_start
291 html += thead_tpl
292 html += thead_end
293
294 tbody = "<tbody>\n"
295 cnt = 0
296 for row in info_list:
297 cnt += 1
298 td_join_tpl = '</td>\n<td {}>'.format(style)
299 row_start = '<tr><td {}>{}</td>\n<td {}>'.format(style, cnt, style)
300 items = [str(x).replace('>', "&#x3e;").replace('<', "&#x3c;") for x in row.values()]
301 row = td_join_tpl.join(items)
302 row_end = '</td>\n</tr>'
303 row_tpl = row_start + row + row_end
304 tbody = tbody + row_tpl + "\n"
305
306 html = html + tbody + "</tbody>" + table_end
307
308 return html
309
310
311def feishu_send(msg, webhook_url, secret, title="灯塔消息推送"):

Callers 2

build_reportMethod · 0.90
_push_emailMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected