Gracefully handle README-parsing failures
This commit is contained in:
parent
0206279894
commit
f717c53e8b
@ -137,20 +137,26 @@ def get_app_features(app_path):
|
|||||||
log.info(f"{app_path}/README.md")
|
log.info(f"{app_path}/README.md")
|
||||||
contents = handle.read()
|
contents = handle.read()
|
||||||
|
|
||||||
for match in findall(r"\*\*.*\s\*", contents):
|
try:
|
||||||
title = search(r"(?<=\*\*).*(?=\*\*)", match).group().lower()
|
for match in findall(r"\*\*.*\s\*", contents):
|
||||||
|
title = search(r"(?<=\*\*).*(?=\*\*)", match).group().lower()
|
||||||
|
|
||||||
if title == "image":
|
if title == "image":
|
||||||
value = {
|
value = {
|
||||||
"image": search(r"(?<=`).*(?=`)", match).group(),
|
"image": search(r"(?<=`).*(?=`)", match).group(),
|
||||||
"url": search(r"(?<=\().*(?=\))", match).group(),
|
"url": search(r"(?<=\().*(?=\))", match).group(),
|
||||||
"rating": match.split(",")[1].strip(),
|
"rating": match.split(",")[1].strip(),
|
||||||
"source": match.split(",")[-1].replace("*", "").strip(),
|
"source": match.split(",")[-1].replace("*", "").strip(),
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
value = match.split(":")[-1].replace("*", "").strip()
|
value = match.split(":")[-1].replace("*", "").strip()
|
||||||
|
|
||||||
features[title] = value
|
features[title] = value
|
||||||
|
except (IndexError, AttributeError):
|
||||||
|
log.info(f"Can't parse {app_path}/README.md")
|
||||||
|
return {}
|
||||||
|
finally:
|
||||||
|
_run_cmd("git checkout HEAD")
|
||||||
|
|
||||||
log.info(f"Parsed {features}")
|
log.info(f"Parsed {features}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user