Changed how .0 is handled

This commit is contained in:
Lucas
2025-04-10 21:29:13 -07:00
parent 298224d7c1
commit 1d0dd945e0

View File

@@ -13,19 +13,14 @@ def extract_repo_path(link):
def format_stars(n):
if n >= 1_000_000:
value = n / 1_000_000
suffix = 'M'
formatted = f"{n/1_000_000:.1f}M"
return formatted.replace('.0M', 'M')
elif n >= 1_000:
value = n / 1_000
suffix = 'k'
formatted = f"{n/1_000:.1f}k"
return formatted.replace('.0k', 'k')
else:
return str(n)
if value.is_integer():
return f"{int(value)}{suffix}"
else:
return f"{value:.1f}{suffix}"
def generate_contents(platform="all"):
with open("source/data/categories.json", "r", encoding="utf-8") as f: