本文整理汇总了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