summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bs4/builder
diff options
context:
space:
mode:
authorDaniel Lublin <daniel@lublin.se>2016-12-05 18:42:05 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-26 13:19:51 +0100
commit924e576b8930fd2268d85f0b151e5f68a3c2afce (patch)
tree0d042cfb8acdce78c6768e148ad4b474d58890ad /bitbake/lib/bs4/builder
parente292e935b077a95ae093d4b425c7e95b177b030b (diff)
downloadpoky-924e576b8930fd2268d85f0b151e5f68a3c2afce.tar.gz
bitbake: lib/bs4: Fix imports from html5lib >= 0.9999999/1.0b8
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. (Bitbake rev: bdf7a362ecdafd47f309b7a21feac4b94624f287) Signed-off-by: Daniel Lublin <daniel@lublin.se> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bs4/builder')
-rw-r--r--bitbake/lib/bs4/builder/_html5lib.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/bitbake/lib/bs4/builder/_html5lib.py b/bitbake/lib/bs4/builder/_html5lib.py
index f0e5924ebb..2b7a70aa11 100644
--- a/bitbake/lib/bs4/builder/_html5lib.py
+++ b/bitbake/lib/bs4/builder/_html5lib.py
@@ -15,7 +15,14 @@ from bs4.element import (
15 whitespace_re, 15 whitespace_re,
16) 16)
17import html5lib 17import html5lib
18try:
19 # html5lib >= 0.99999999/1.0b9
20 from html5lib.treebuilders import base as treebuildersbase
21except ImportError:
22 # html5lib <= 0.9999999/1.0b8
23 from html5lib.treebuilders import _base as treebuildersbase
18from html5lib.constants import namespaces 24from html5lib.constants import namespaces
25
19from bs4.element import ( 26from bs4.element import (
20 Comment, 27 Comment,
21 Doctype, 28 Doctype,
@@ -67,7 +74,7 @@ class HTML5TreeBuilder(HTMLTreeBuilder):
67 return '<html><head></head><body>%s</body></html>' % fragment 74 return '<html><head></head><body>%s</body></html>' % fragment
68 75
69 76
70class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder): 77class TreeBuilderForHtml5lib(treebuildersbase.TreeBuilder):
71 78
72 def __init__(self, soup, namespaceHTMLElements): 79 def __init__(self, soup, namespaceHTMLElements):
73 self.soup = soup 80 self.soup = soup
@@ -105,7 +112,7 @@ class TreeBuilderForHtml5lib(html5lib.treebuilders._base.TreeBuilder):
105 return self.soup 112 return self.soup
106 113
107 def getFragment(self): 114 def getFragment(self):
108 return html5lib.treebuilders._base.TreeBuilder.getFragment(self).element 115 return treebuildersbase.TreeBuilder.getFragment(self).element
109 116
110class AttrList(object): 117class AttrList(object):
111 def __init__(self, element): 118 def __init__(self, element):
@@ -137,9 +144,9 @@ class AttrList(object):
137 return name in list(self.attrs.keys()) 144 return name in list(self.attrs.keys())
138 145
139 146
140class Element(html5lib.treebuilders._base.Node): 147class Element(treebuildersbase.Node):
141 def __init__(self, element, soup, namespace): 148 def __init__(self, element, soup, namespace):
142 html5lib.treebuilders._base.Node.__init__(self, element.name) 149 treebuildersbase.Node.__init__(self, element.name)
143 self.element = element 150 self.element = element
144 self.soup = soup 151 self.soup = soup
145 self.namespace = namespace 152 self.namespace = namespace
@@ -324,7 +331,7 @@ class Element(html5lib.treebuilders._base.Node):
324 331
325class TextNode(Element): 332class TextNode(Element):
326 def __init__(self, element, soup): 333 def __init__(self, element, soup):
327 html5lib.treebuilders._base.Node.__init__(self, None) 334 treebuildersbase.Node.__init__(self, None)
328 self.element = element 335 self.element = element
329 self.soup = soup 336 self.soup = soup
330 337