mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 01:57:48 -06:00
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.
16 lines
529 B
Python
16 lines
529 B
Python
"""Byte counts as the README, the site and the release notes print them."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
def size_text(count: int) -> str:
|
|
"""A byte count in the largest binary unit it reaches, one decimal: 29.2 MB.
|
|
|
|
The installer prints the same text (installer/text.py format_size), so a
|
|
figure reads alike on every surface.
|
|
"""
|
|
for unit, scale in (("GB", 1024**3), ("MB", 1024**2), ("KB", 1024)):
|
|
if count >= scale:
|
|
return f"{count / scale:.1f} {unit}"
|
|
return f"{count} B"
|