diff --git a/source/scripts/generation/contents_generator.py b/source/scripts/generation/contents_generator.py index 26215d8..ba39371 100644 --- a/source/scripts/generation/contents_generator.py +++ b/source/scripts/generation/contents_generator.py @@ -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: