mirror of
https://github.com/ihabunek/toot.git
synced 2025-01-03 14:56:37 -05:00
Ignore bs4 warnings
These are triggered by false positives and get printed to screen when running `toot curses`.
This commit is contained in:
parent
7bcf868469
commit
0dfb04e9e3
@ -4,6 +4,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
import warnings
|
||||||
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
@ -17,6 +18,12 @@ def str_bool(b):
|
|||||||
|
|
||||||
def get_text(html):
|
def get_text(html):
|
||||||
"""Converts html to text, strips all tags."""
|
"""Converts html to text, strips all tags."""
|
||||||
|
|
||||||
|
# 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()
|
text = BeautifulSoup(html.replace(''', "'"), "html.parser").get_text()
|
||||||
|
|
||||||
return unicodedata.normalize('NFKC', text)
|
return unicodedata.normalize('NFKC', text)
|
||||||
|
Loading…
Reference in New Issue
Block a user