scripts/update-plugin-list: escape summary for special RST chars

A new plugin has this summary:

    Continiously runs pytest on changes in *.py files

The `*` is interpreted as a special character and fails the CI.

Add some rudimentary escaping to hopefully prevent this.
This commit is contained in:
Ran Benita
2021-09-22 16:29:37 +03:00
parent 3f404418bf
commit 4ae4bec968
2 changed files with 38 additions and 24 deletions

View File

@@ -26,6 +26,20 @@ DEVELOPMENT_STATUS_CLASSIFIERS = (
)
def escape_rst(text: str) -> str:
"""Rudimentary attempt to escape special RST characters to appear as
plain text."""
text = (
text
.replace("*", "\\*")
.replace("<", "\\<")
.replace(">", "\\>")
.replace("`", "\\`")
)
text = re.sub(r"_\b", "", text)
return text
def iter_plugins():
regex = r">([\d\w-]*)</a>"
response = requests.get("https://pypi.org/simple")
@@ -63,8 +77,7 @@ def iter_plugins():
last_release = release_date.strftime("%b %d, %Y")
break
name = f'`{info["name"]} <{info["project_url"]}>`_'
summary = info["summary"].replace("\n", "")
summary = re.sub(r"_\b", "", summary)
summary = escape_rst(info["summary"].replace("\n", ""))
yield {
"name": name,
"summary": summary,