本文整理匯總了Python中html5lib.treebuilders._base.TreeBuilder方法的典型用法代碼示例。如果您正苦於以下問題:Python _base.TreeBuilder方法的具體用法?Python _base.TreeBuilder怎麽用?Python _base.TreeBuilder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類html5lib.treebuilders._base
的用法示例。
在下文中一共展示了_base.TreeBuilder方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: prepare_markup
# 需要導入模塊: from html5lib.treebuilders import _base [as 別名]
# 或者: from html5lib.treebuilders._base import TreeBuilder [as 別名]
def prepare_markup(self, markup, user_specified_encoding,
document_declared_encoding=None, exclude_encodings=None):
# Store the user-specified encoding for use later on.
self.user_specified_encoding = user_specified_encoding
# document_declared_encoding and exclude_encodings aren't used
# ATM because the html5lib TreeBuilder doesn't use
# UnicodeDammit.
if exclude_encodings:
warnings.warn("You provided a value for exclude_encoding, but the html5lib tree builder doesn't support exclude_encoding.")
yield (markup, None, None, False)
# These methods are defined by Beautiful Soup.
示例2: test_fragment_to_document
# 需要導入模塊: from html5lib.treebuilders import _base [as 別名]
# 或者: from html5lib.treebuilders._base import TreeBuilder [as 別名]
def test_fragment_to_document(self, fragment):
"""See `TreeBuilder`."""
return '<html><head></head><body>%s</body></html>' % fragment
示例3: getFragment
# 需要導入模塊: from html5lib.treebuilders import _base [as 別名]
# 或者: from html5lib.treebuilders._base import TreeBuilder [as 別名]
def getFragment(self):
return treebuilder_base.TreeBuilder.getFragment(self).element
示例4: __init__
# 需要導入模塊: from html5lib.treebuilders import _base [as 別名]
# 或者: from html5lib.treebuilders._base import TreeBuilder [as 別名]
def __init__(self, *args, **kwargs):
html_builder = etree_builders.getETreeModule(html, fullTree=False)
etree_builder = etree_builders.getETreeModule(etree, fullTree=False)
self.elementClass = html_builder.Element
self.commentClass = etree_builder.Comment
_base.TreeBuilder.__init__(self, *args, **kwargs)
示例5: reset
# 需要導入模塊: from html5lib.treebuilders import _base [as 別名]
# 或者: from html5lib.treebuilders._base import TreeBuilder [as 別名]
def reset(self):
_base.TreeBuilder.reset(self)
self.rootInserted = False
self.initialComments = []
self.doctype = None
示例6: insertComment
# 需要導入模塊: from html5lib.treebuilders import _base [as 別名]
# 或者: from html5lib.treebuilders._base import TreeBuilder [as 別名]
def insertComment(self, data, parent=None):
if not self.rootInserted:
self.initialComments.append(data)
else:
_base.TreeBuilder.insertComment(self, data, parent)
示例7: test_fragment_to_document
# 需要導入模塊: from html5lib.treebuilders import _base [as 別名]
# 或者: from html5lib.treebuilders._base import TreeBuilder [as 別名]
def test_fragment_to_document(self, fragment):
"""See `TreeBuilder`."""
return u'<html><head></head><body>%s</body></html>' % fragment