aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Lublin <daniel@lublin.se>2016-12-05 18:42:05 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-03-28 12:55:22 +0100
commit0d80cacb2b84ee059cee3caf8a5968033b9ce3c5 (patch)
treee059cce4de7c52bedf5aee859ebc006e15b2d345
parent919303d2e8b4ee2602b09420f40b70de091612c5 (diff)
downloadbitbake-1.28.tar.gz
bitbake-1.28.tar.bz2
bitbake-1.28.zip
lib/bs4: Fix imports from html5lib >= 0.9999999/1.0b81.28
As of html5lib 0.9999999/1.0b8 (released on July 14, 2016), some modules have moved from _base to base. Handle this, while staying compatible with earlier versions. Signed-off-by: Daniel Lublin <daniel@lublin.se> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bs4/builder/_html5lib.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/bs4/builder/_html5lib.py b/lib/bs4/builder/_html5lib.py
index 7de36ae7..0f4007a9 100644
--- a/lib/bs4/builder/_html5lib.py
+++ b/lib/bs4/builder/_html5lib.py
@@ -11,7 +11,14 @@ from bs4.builder import (
)
from bs4.element import NamespacedAttribute
import html5lib
+try:
+ # html5lib >= 0.99999999/1.0b9
+ from html5lib.treebuilders import base as treebuildersbase
+except ImportError:
+ # html5lib <= 0.9999999/1.0b8
+ from html5lib.treebuilders import _base as treebuildersbase
from html5lib.constants import namespaces
+
from bs4.element import (
Comment,
Doctype,
@@ -54,7 +61,7 @@ class HTML5TreeBuilder(HTMLTreeBuilder):
return u'<html><head></head><body>%s</body></html>' % fragment
-class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
+class TreeBuilderForHtml5lib(treebuildersbase.TreeBuilder):
def __init__(self, soup, namespaceHTMLElements):
self.soup = soup
@@ -92,7 +99,7 @@ class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
return self.soup
def getFragment(self):
- return html5lib.treebuilders._base.TreeBuilder.getFragment(self).element
+ return treebuildersbase.TreeBuilder.getFragment(self).element
class AttrList(object):
def __init__(self, element):
@@ -115,9 +122,9 @@ class AttrList(object):
return name in list(self.attrs.keys())
-class Element(html5lib.treebuilders._base.Node):
+class Element(treebuildersbase.Node):
def __init__(self, element, soup, namespace):
- html5lib.treebuilders._base.Node.__init__(self, element.name)
+ treebuildersbase.Node.__init__(self, element.name)
self.element = element
self.soup = soup
self.namespace = namespace
@@ -277,7 +284,7 @@ class Element(html5lib.treebuilders._base.Node):
class TextNode(Element):
def __init__(self, element, soup):
- html5lib.treebuilders._base.Node.__init__(self, None)
+ treebuildersbase.Node.__init__(self, None)
self.element = element
self.soup = soup