(sources: list[AnnotatedSource])
| 432 | |
| 433 | |
| 434 | def generate_html_report(sources: list[AnnotatedSource]) -> str: |
| 435 | html = [] |
| 436 | html.append("<html>\n<head>\n") |
| 437 | html.append(f"<style>\n{CSS}\n</style>") |
| 438 | html.append("</head>\n") |
| 439 | html.append("<body>\n") |
| 440 | for src in sources: |
| 441 | html.append(f"<h2><tt>{src.path}</tt></h2>\n") |
| 442 | html.append("<pre>") |
| 443 | src_anns = src.annotations |
| 444 | with open(src.path) as f: |
| 445 | lines = f.readlines() |
| 446 | for i, s in enumerate(lines): |
| 447 | s = escape(s) |
| 448 | line = i + 1 |
| 449 | linenum = "%5d" % line |
| 450 | if line in src_anns: |
| 451 | anns = get_max_prio(src_anns[line]) |
| 452 | ann_strs = [a.message for a in anns] |
| 453 | hint = " ".join(ann_strs) |
| 454 | s = colorize_line(linenum, s, hint_html=hint) |
| 455 | else: |
| 456 | s = linenum + " " + s |
| 457 | html.append(s) |
| 458 | html.append("</pre>") |
| 459 | |
| 460 | html.append("<script>") |
| 461 | html.append(JS) |
| 462 | html.append("</script>") |
| 463 | |
| 464 | html.append("</body></html>\n") |
| 465 | return "".join(html) |
| 466 | |
| 467 | |
| 468 | def colorize_line(linenum: str, s: str, hint_html: str) -> str: |
no test coverage detected
searching dependent graphs…