refactor: print sizes with one function

core.sizes.size_text replaces readme format_size, release record
size_text, render fmt_size, the large-files notes _mib and the handheld
_size. It prints one decimal in the largest unit reached, as the site
and the installer already did.

The README download table, the release notes and the large-files page
now say 29.2 MB where they said 29 MB, a handheld archive says 85.3 KB
where it said 85 KB, and a large-files asset under 1 MB is given in KB.
This commit is contained in:
Abdessamad Derraz committed 2026-11-20 20:03:26 +01:00
1 parent 3a76cf48ba
commit ab0805e6cb
19 files changed
+60 -71

No files matched your search

+3 -3
View File
@@ -16,6 +16,7 @@ from sitegen import entries as siteentries, markup
from sitegen.cards import SHORT_HASH
from sitegen.config import REPO_URL, date_line
from core.paths import REPO_ROOT
from core.sizes import size_text
from sitegen.fields import hash_spans, search_excluded
from sitegen.parts import (
PAGE_BYTES,
@@ -32,7 +33,6 @@ from sitegen.render import (
count_text,
emulator_link,
escape_tags,
fmt_size,
card_page,
console_href,
)
@@ -276,9 +276,9 @@ def _platform_file_row(f: dict, cfg_entry: dict, hash_type: str = "",
# The size closes the hash lines: a line of its own was one more
# element per row.
if size and facts:
facts[-1] += f" ({fmt_size(size)})"
facts[-1] += f" ({size_text(size)})"
elif size:
facts.append(f"Size: {fmt_size(size)}")
facts.append(f"Size: {size_text(size)}")
if f.get("status") == "untested" and f.get("reason"):
facts.append(_text_html(f"Not confirmed: {f['reason']}"))
# Not every entry is firmware: the platform may list a game's data or a