diff --git a/toot/utils.py b/toot/utils.py index 6575698..2508e5a 100644 --- a/toot/utils.py +++ b/toot/utils.py @@ -4,6 +4,7 @@ import os import re import socket import unicodedata +import warnings from bs4 import BeautifulSoup @@ -17,7 +18,13 @@ def str_bool(b): def get_text(html): """Converts html to text, strips all tags.""" - text = BeautifulSoup(html.replace(''', "'"), "html.parser").get_text() + + # Ignore warnings made by BeautifulSoup, if passed something that looks like + # a file (e.g. a dot which matches current dict), it will warn that the file + # should be opened instead of passing a filename. + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + text = BeautifulSoup(html.replace(''', "'"), "html.parser").get_text() return unicodedata.normalize('NFKC', text)