mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 18:17:53 -06:00
fix: print byte counts with size_text
This commit is contained in:
1 parent
49a8ed801e
commit
4f6bb08e2a
5 files changed
+16
-5
No files matched your search
@@ -19,6 +19,7 @@ import json
|
||||
from pathlib import Path
|
||||
|
||||
from core.hashing import compute_hashes
|
||||
from core.sizes import size_text
|
||||
from resolve.directories import expand_directory_entries
|
||||
from model.registry import list_registered_platforms
|
||||
from model.database import load_database
|
||||
@@ -132,7 +133,7 @@ def main() -> int:
|
||||
print(f"{row['path']} ({', '.join(row['emulators'])})")
|
||||
total = sum(row["size"] for row in rows)
|
||||
print(f"{len(rows)} collected files only an emulator install provides, "
|
||||
f"{total / 1024**2:.1f} MB")
|
||||
f"{size_text(total)}")
|
||||
return 1 if args.strict and rows else 0
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -29,6 +29,7 @@ from pathlib import Path
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from core.hashing import compute_hashes
|
||||
from core.sizes import size_text
|
||||
from core.cli import add_repo_inputs, require_directory
|
||||
from core.artifacts import write_text_atomic
|
||||
from model.nodedup import in_nodedup_dir
|
||||
@@ -298,7 +299,7 @@ def deduplicate(bios_dir: str, dry_run: bool = False) -> dict:
|
||||
prefix = "Would remove" if dry_run else "Removed"
|
||||
print(f"\n{prefix}: {total_removed} files")
|
||||
print(
|
||||
f"Space {'to save' if dry_run else 'saved'}: {total_saved / 1024 / 1024:.1f} MB"
|
||||
f"Space {'to save' if dry_run else 'saved'}: {size_text(total_saved)}"
|
||||
)
|
||||
if not dry_run and empty_cleaned:
|
||||
print(f"Cleaned {empty_cleaned} empty directories")
|
||||
|
||||
+3
-2
@@ -33,6 +33,7 @@ from pathlib import Path
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from core.hashing import compute_hashes, parse_sha256sums
|
||||
from core.paths import REPO_ROOT
|
||||
from core.sizes import size_text
|
||||
from core.upstream import forge_headers
|
||||
from core.ziptools import safe_extract_zip
|
||||
from packs.parts import part_of
|
||||
@@ -239,7 +240,7 @@ def _progress_line(label: str, done: int, total: int, columns: int) -> str:
|
||||
copy of itself on every redraw, since \\r goes back one row only. The
|
||||
bar shrinks first, then goes."""
|
||||
pct = done * 100 // total
|
||||
figures = f" {pct}% ({done / 1e6:,.0f}/{total / 1e6:,.0f} MB)"
|
||||
figures = f" {pct}% ({size_text(done)}/{size_text(total)})"
|
||||
room = min(50, columns - 1 - len(f" {label}[]") - len(figures))
|
||||
if room < 10:
|
||||
return f" {label}{figures.strip()}"[: columns - 1]
|
||||
@@ -333,7 +334,7 @@ def show_info(platform: str, release: dict) -> None:
|
||||
print(f" Platform: {pack.platform}")
|
||||
print(f" File: {pack.name}")
|
||||
print(f" Parts: {len(pack.parts)} part{'s' if len(pack.parts) > 1 else ''}")
|
||||
print(f" Size: {pack.size:,} bytes ({pack.size / (1024 * 1024):.1f} MB)")
|
||||
print(f" Size: {pack.size:,} bytes ({size_text(pack.size)})")
|
||||
for part in pack.parts:
|
||||
print(f" {part['name']} ({part.get('size', 0):,} bytes)")
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ def render_notes(
|
||||
out += ["| File | Description | Size | SHA1 |", "|------|-------------|-----:|------|"]
|
||||
out += [line for _, line in sorted(rows[section])]
|
||||
total = sum(assets.values())
|
||||
out += ["", f"{len(assets)} files, {total / 1073741824:.1f} GB total. Verify a download with `sha1sum <file>`.", ""]
|
||||
out += ["", f"{len(assets)} files, {size_text(total)} total. Verify a download with `sha1sum <file>`.", ""]
|
||||
return "\n".join(out)
|
||||
|
||||
|
||||
|
||||
@@ -288,6 +288,14 @@ class TestProgressLineWidth(unittest.TestCase):
|
||||
self.assertLess(len(line), columns)
|
||||
self.assertIn("%", line)
|
||||
|
||||
def test_the_figures_read_like_the_site(self):
|
||||
"""The bar counted decimal megabytes (8,127 MB) where --info and the
|
||||
site gave the same pack as 7.6 GB."""
|
||||
from download import _progress_line
|
||||
|
||||
line = _progress_line("", 1024**3, 8_127_352_876, 200)
|
||||
self.assertTrue(line.endswith(" 13% (1.0 GB/7.6 GB)"), line)
|
||||
|
||||
|
||||
class TestStagingIsolation(unittest.TestCase):
|
||||
"""Two downloads into one BIOS folder must not share a staging directory."""
|
||||
|
||||
Reference in new issue
Block a user