Skip to content

Commit ff1e570

Browse files
committed
Added truncate trailing .0 to format_total()
1 parent a4d9166 commit ff1e570

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

utils/update_root_shield.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ def get_downloads(pkg: str, max_retries: int = 5, get_delay: int = 1) -> int:
4646
return 0
4747

4848
def format_total(num: int) -> str: # abbr ints to e.g. 1.5k, 2b
49-
return f'{num / 1000000000:.1f}B' if num >= 1000000000 \
50-
else f'{num / 1000000:.1f}M' if num >= 1000000 \
51-
else f'{num / 1000:.1f}K' if num >= 1000 \
52-
else str(num)
49+
return (
50+
f'{num / 1000000000:.1f}B' if num >= 1000000000
51+
else f'{num / 1000000:.1f}M' if num >= 1000000
52+
else f'{num / 1000:.1f}K' if num >= 1000
53+
else str(num)
54+
).replace('.0', '')
5355

5456
def read_file(file_path: str) -> list[str]:
5557
with open(file_path, 'r', encoding='utf-8') as file:

0 commit comments

Comments
 (0)