Skip to content

Commit

Permalink
Update wiki_tu to new report format (#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribbanya authored Sep 26, 2024
1 parent 567e18b commit 5a3394c
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions tools/wiki_tu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@

import humanfriendly
import mistletoe
from mistletoe.block_token import (
BlockToken,
Table,
TableRow,
re,
)
from mistletoe.block_token import BlockToken, Table, TableRow, re
from mistletoe.span_token import RawText
from mistletoe.token import Token

Expand Down Expand Up @@ -86,23 +81,21 @@ def write(args):
)
for unit in data["units"] or []:

def friendly_size(key: str) -> str:
return (
f"`{humanfriendly.format_size(unit[key] or 0).replace('bytes', 'B')}`"
)
def friendly_size(value: int) -> str:
return f"`{humanfriendly.format_size(value).replace('bytes', 'B')}`"

# Strip "main/" by splitting on "/" and recombining
file = "/".join((unit["name"] or "/").split("/")[1:])
# Link to source file
file_link = f"[`{file}`](../blob/master/src/{file}.c)"

matched_code = float(unit["matched_code"])
total_code = float(unit["total_code"])
code_percent = (matched_code / total_code if total_code else 0) * 100
matched = f"{friendly_size('matched_code')}"
total = f"{friendly_size('total_code')}"
matched_code = int(unit["measures"].get("matched_code") or 0)
total_code = int(unit["measures"].get("total_code") or 0)
code_percent = float(unit["measures"].get("matched_code_percent") or 0)
matched = f"{friendly_size(matched_code)}"
total = f"{friendly_size(total_code)}"
percent = f"`{humanfriendly.round_number(code_percent)}%`"
linked = ":heavy_check_mark:" if unit["complete"] else ":x:"
linked = ":heavy_check_mark:" if unit["metadata"].get("complete") else ":x:"

if assignee := assignees.get(file):
discord = f"`{assignee['discord']}`"
Expand Down

0 comments on commit 5a3394c

Please sign in to comment.