fix regex for finding gitlab_id in reponse.text

This commit is contained in:
Trent Palmer 2024-05-24 12:46:00 -07:00
parent f16129da39
commit c92d2f876e

View File

@ -213,7 +213,9 @@ def parse_hugo_themes_list():
def get_gitlab_project_ids(): def get_gitlab_project_ids():
session = sessionmaker(bind=engine)() session = sessionmaker(bind=engine)()
themes = (theme[0] for theme in session.query(Hugothemes_from_gitlab.name).all()) themes = (theme[0] for theme in session.query(Hugothemes_from_gitlab.name).all())
match = re.compile(r"(Project ID: )(\d{5,})") # match = re.compile(r"(Project ID: )(\d{5,})")
# need new regex gitlab moved my cheese
match = re.compile(r"(Project\/)(\d{8})")
for theme in themes: for theme in themes:
gitlab_theme = session.query(Hugothemes_from_gitlab).filter_by(name=theme).one() gitlab_theme = session.query(Hugothemes_from_gitlab).filter_by(name=theme).one()
if gitlab_theme.gitlab_id is None: if gitlab_theme.gitlab_id is None:
@ -685,18 +687,20 @@ def generate_report():
"url": f"https://{theme.url}", "url": f"https://{theme.url}",
"short_name": theme.name.split("/")[1], "short_name": theme.name.split("/")[1],
"num_stars": theme.stargazers_count, "num_stars": theme.stargazers_count,
"tags": literal_eval(theme.tags_list) "tags": (
if theme.tags_list is not None literal_eval(theme.tags_list) if theme.tags_list is not None else []
else [], ),
"features": literal_eval(theme.features_list) "features": (
if theme.features_list is not None literal_eval(theme.features_list)
else [], if theme.features_list is not None
else []
),
"license": theme.theme_license if theme.theme_license is not None else "", "license": theme.theme_license if theme.theme_license is not None else "",
"min_ver": theme.min_ver if theme.min_ver is not None else "", "min_ver": theme.min_ver if theme.min_ver is not None else "",
"desc": theme.desc if theme.desc is not None else "", "desc": theme.desc if theme.desc is not None else "",
"cname": theme.cname "cname": (
if theme.cname is not None theme.cname if theme.cname is not None else theme.name.split("/")[1]
else theme.name.split("/")[1], ),
} }
for theme in session.query(Hugothemes).all() for theme in session.query(Hugothemes).all()
] ]