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
@@ -22,11 +22,11 @@ from resolve.nativemode import digest_algorithm
from installer_build.handhelds import GROUP_PAGE
from sitegen import handheld as sitehandheld, markup
from core.paths import REPO_ROOT
from core.sizes import size_text
from sitegen.guides import platform_args, terminal_tabs
from sitegen.home import next_block
from sitegen.install import installer_module, has_release_pack
from sitegen.readme import download_links, extract_notes
from sitegen.render import fmt_size
from sitegen.versions import release_line, setup_version, version_line
@@ -316,8 +316,8 @@ def _guide_download(name: str, display: str, guide: Guide, extract_to: str | Non
if pack and pack.get("assets"):
parts = len(pack["assets"])
bullets = [
f"{fmt_size(pack['download_size'])} to download, "
f"{fmt_size(pack['extracted_size'])} once unzipped."
f"{size_text(pack['download_size'])} to download, "
f"{size_text(pack['extracted_size'])} once unzipped."
]
if parts > 1:
bullets.append("Both parts are needed." if parts == 2 else f"All {parts} parts are needed.")