From 891a8fe4e37cc2841158b425bf365fb097050823 Mon Sep 17 00:00:00 2001 From: Trent Palmer Date: Thu, 31 Aug 2023 18:32:54 -0700 Subject: [PATCH] new get_vnum_stripped_string function --- rank_hugo_themes.py | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/rank_hugo_themes.py b/rank_hugo_themes.py index 875a405..6af4114 100755 --- a/rank_hugo_themes.py +++ b/rank_hugo_themes.py @@ -190,18 +190,7 @@ def parse_gitlab_hugo_themes_list(): def get_corrected_url(x): - if "neofeed-theme" in x: - return x.rstrip("/v2") - elif "salinger-theme" in x: - return x.rstrip("/v2") - elif "docuapi" in x: - return x.rstrip("/v2") - elif "bilberry-hugo-theme" in x: - return x.rstrip("/v3") - elif "hugo-liftoff" in x: - return x.rstrip("/v3") - else: - return x + return get_vnum_stripped_string(x) def parse_hugo_themes_list(): @@ -236,22 +225,12 @@ def get_gitlab_project_ids(): def get_corrected_theme_name(x): - if "neofeed-theme" in x: - return x.rstrip("/v2") - elif "docuapi" in x: - return x.rstrip("/v2") - elif "hugo-theme-zen" in x: - return x.rstrip("/v2") - elif "salinger-theme" in x: - return x.rstrip("/v2") - elif "osprey-delight" in x: - return x.rstrip("/v5") - elif "bilberry-hugo-theme" in x: - return x.rstrip("/v3") - elif "hugo-theme-stack" in x: - return x.rstrip("/v3") - elif "hugo-liftoff" in x: - return x.rstrip("/v3") + return get_vnum_stripped_string(x) + + +def get_vnum_stripped_string(x): + if x[-3:] in ("/v2", "/v3", "/v4", "/v5"): + return x[0:-3] else: return x