Skip to content

Commit 030a4b4

Browse files
authored
Merge pull request #46 from SmithChart/bs4-no-more-warnings
Context: Filter MarkupResemblesLocatorWarning from BeautifulSoup
2 parents 1c6edfc + 85f817a commit 030a4b4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

flamingo/core/context.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import logging
22
import shutil
33
import os
4+
import warnings
5+
6+
import bs4
47

58
from flamingo.core.data_model import ContentSet, AND, NOT, OR, Q, F
69
from flamingo.core.plugins.plugin_manager import PluginManager
@@ -34,6 +37,16 @@ def setup(self):
3437
self.logger = logging.getLogger('flamingo')
3538
self.logger.debug('setting up context')
3639

40+
# BS4: Filter MarkupResemblesLocatorWarning
41+
# BS4 emits warnings when we try to parse strings that look like a
42+
# path or url. So if we parse some content that may only contain
43+
# something that looks like a path or url, but is a valid content,
44+
# we would be greeted with a MarkupResemblesLocatorWarning.
45+
warnings.filterwarnings(
46+
"ignore",
47+
category=bs4.MarkupResemblesLocatorWarning,
48+
)
49+
3750
# setup plugins
3851
self.plugins = PluginManager(self)
3952
self.plugins.run_plugin_hook('setup')

0 commit comments

Comments
 (0)