(info_list)
| 275 | |
| 276 | |
| 277 | def 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('>', ">").replace('<', "<") 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 | |
| 311 | def feishu_send(msg, webhook_url, secret, title="灯塔消息推送"): |
no outgoing calls
no test coverage detected