python: Normalize quotes with Black.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-02-11 23:20:45 -08:00
committed by Tim Abbott
parent 11741543da
commit 6e4c3e41dc
989 changed files with 32792 additions and 32792 deletions

View File

@@ -7,20 +7,20 @@ from django.utils.html import escape
from zerver.lib.cache import cache_with_key, open_graph_description_cache_key
def html_to_text(content: Union[str, bytes], tags: Mapping[str, str] = {'p': ' | '}) -> str:
bs = BeautifulSoup(content, features='lxml')
def html_to_text(content: Union[str, bytes], tags: Mapping[str, str] = {"p": " | "}) -> str:
bs = BeautifulSoup(content, features="lxml")
# Skip any admonition (warning) blocks, since they're
# usually something about users needing to be an
# organization administrator, and not useful for
# describing the page.
for tag in bs.find_all('div', class_="admonition"):
for tag in bs.find_all("div", class_="admonition"):
tag.clear()
# Skip code-sections, which just contains navigation instructions.
for tag in bs.find_all('div', class_="code-section"):
for tag in bs.find_all("div", class_="code-section"):
tag.clear()
text = ''
text = ""
for element in bs.find_all(tags.keys()):
# Ignore empty elements
if not element.text:
@@ -31,7 +31,7 @@ def html_to_text(content: Union[str, bytes], tags: Mapping[str, str] = {'p': ' |
text += element.text
if len(text) > 500:
break
return escape(' '.join(text.split()))
return escape(" ".join(text.split()))
@cache_with_key(open_graph_description_cache_key, timeout=3600 * 24)