mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-25 19:08:51 -06:00
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:
1 parent
3a76cf48ba
commit
ab0805e6cb
19 files changed
+60
-71
No files matched your search
@@ -12,6 +12,7 @@ from typing import NamedTuple
|
||||
|
||||
from core.paths import EMULATORS_DIR
|
||||
from core.hashing import file_digest
|
||||
from core.sizes import size_text
|
||||
from model.composition import composition_tier
|
||||
from model.largefiles import LARGE_FILES_RELEASE, LARGE_FILES_REPO, asset_names, registered_paths
|
||||
|
||||
@@ -157,10 +158,6 @@ def _section_for(path: str) -> str:
|
||||
return "Other"
|
||||
|
||||
|
||||
def _mib(size: int) -> str:
|
||||
return f"{round(size / 1048576)} MB"
|
||||
|
||||
|
||||
def render_notes(
|
||||
db: dict,
|
||||
gitignore_text: str,
|
||||
@@ -205,9 +202,9 @@ def render_notes(
|
||||
description = description or name
|
||||
link = f"[{name}]({ASSET_URL}{name})"
|
||||
if section == NOT_INDEXED:
|
||||
line = f"| {link} | {description} | {_mib(size)} |"
|
||||
line = f"| {link} | {description} | {size_text(size)} |"
|
||||
else:
|
||||
line = f"| {link} | {description} | {_mib(size)} | `{sha1}` |"
|
||||
line = f"| {link} | {description} | {size_text(size)} | `{sha1}` |"
|
||||
rows[section].append((-size, line))
|
||||
|
||||
out = [
|
||||
|
||||
@@ -7,6 +7,7 @@ import re
|
||||
import subprocess
|
||||
from collections.abc import Callable
|
||||
|
||||
from core.sizes import size_text
|
||||
from model.guides import install_command
|
||||
from model.platforms import load_platform_config
|
||||
from model.registry import (
|
||||
@@ -14,7 +15,6 @@ from model.registry import (
|
||||
list_release_pack_platforms,
|
||||
load_platform_registry,
|
||||
)
|
||||
from release import record as release_record
|
||||
|
||||
|
||||
REPO = "Abdess/retrobios"
|
||||
@@ -240,7 +240,7 @@ def render(record: dict, platforms_dir: str, whats_new: str,
|
||||
folder = folders.get(name)
|
||||
lines.append(
|
||||
f"| {_display(name)} | {_link(pack, tag)} |"
|
||||
f" {release_record.size_text(pack['extracted_size'])} | {pack['files']:,} |"
|
||||
f" {size_text(pack['extracted_size'])} | {pack['files']:,} |"
|
||||
f" {f'`{folder}`' if folder else '-'} |"
|
||||
)
|
||||
lines += [
|
||||
|
||||
@@ -115,9 +115,3 @@ def manifest_mismatches(record: dict, install_dir: str | Path) -> list[str]:
|
||||
f"install/{manifest_path.name} expects {expected}"
|
||||
)
|
||||
return found
|
||||
|
||||
|
||||
def size_text(count: int) -> str:
|
||||
if count >= 1024**3:
|
||||
return f"{count / 1024**3:.1f} GB"
|
||||
return f"{count / 1024**2:.0f} MB"
|
||||
Reference in new issue
Block a user