当前位置: 首页>>代码示例>>Python>>正文


Python HTMLInputStream.charsUntil方法代码示例

本文整理汇总了Python中html5lib.inputstream.HTMLInputStream.charsUntil方法的典型用法代码示例。如果您正苦于以下问题:Python HTMLInputStream.charsUntil方法的具体用法?Python HTMLInputStream.charsUntil怎么用?Python HTMLInputStream.charsUntil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在html5lib.inputstream.HTMLInputStream的用法示例。


在下文中一共展示了HTMLInputStream.charsUntil方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_newlines

# 需要导入模块: from html5lib.inputstream import HTMLInputStream [as 别名]
# 或者: from html5lib.inputstream.HTMLInputStream import charsUntil [as 别名]
 def test_newlines(self):
     stream = HTMLInputStream(codecs.BOM_UTF8 + "a\nbb\r\nccc\rddddxe")
     self.assertEquals(stream.position(), (1, 0))
     self.assertEquals(stream.charsUntil('c'), u"a\nbb\n")
     self.assertEquals(stream.position(), (3, 0))
     self.assertEquals(stream.charsUntil('x'), u"ccc\ndddd")
     self.assertEquals(stream.position(), (4, 4))
     self.assertEquals(stream.charsUntil('e'), u"x")
     self.assertEquals(stream.position(), (4, 5))
开发者ID:alabid,项目名称:html5lib,代码行数:11,代码来源:test_stream.py

示例2: test_position

# 需要导入模块: from html5lib.inputstream import HTMLInputStream [as 别名]
# 或者: from html5lib.inputstream.HTMLInputStream import charsUntil [as 别名]
 def test_position(self):
     stream = HTMLInputStream(codecs.BOM_UTF8 + "a\nbb\nccc\nddd")
     self.assertEquals(stream.position(), (1, 0))
     self.assertEquals(stream.charsUntil('c'),u"a\nbb\n")
     self.assertEquals(stream.position(), (3, 0))
     stream.unget("a\nbb\n")
     self.assertEquals(stream.position(), (1, 0))
     self.assertEquals(stream.charsUntil('c'),u"a\nbb\n")
     self.assertEquals(stream.position(), (3, 0))
     stream.unget("\n")
     self.assertEquals(stream.char(), u"\n")
     self.assertEquals(stream.position(), (3, 0))
     self.assertEquals(stream.charsUntil('e'),u"ccc\nddd")
     self.assertEquals(stream.position(), (4, 3))
开发者ID:yasulab,项目名称:kayak-api-lib4py,代码行数:16,代码来源:test_stream.py

示例3: test_python_issue_20007

# 需要导入模块: from html5lib.inputstream import HTMLInputStream [as 别名]
# 或者: from html5lib.inputstream.HTMLInputStream import charsUntil [as 别名]
    def test_python_issue_20007(self):
        """
        Make sure we have a work-around for Python bug #20007
        http://bugs.python.org/issue20007
        """
        class FakeSocket(object):
            def makefile(self, _mode, _bufsize=None):
                return BytesIO(b"HTTP/1.1 200 Ok\r\n\r\nText")

        source = http_client.HTTPResponse(FakeSocket())
        source.begin()
        stream = HTMLInputStream(source)
        self.assertEqual(stream.charsUntil(" "), "Text")
开发者ID:MaloChevillotte,项目名称:html5lib-python,代码行数:15,代码来源:test_stream.py

示例4: test_python_issue_20007_b

# 需要导入模块: from html5lib.inputstream import HTMLInputStream [as 别名]
# 或者: from html5lib.inputstream.HTMLInputStream import charsUntil [as 别名]
    def test_python_issue_20007_b(self):
        """
        Make sure we have a work-around for Python bug #20007
        http://bugs.python.org/issue20007
        """
        if six.PY2:
            return

        class FakeSocket(object):
            def makefile(self, _mode, _bufsize=None):
                return BytesIO(b"HTTP/1.1 200 Ok\r\n\r\nText")

        source = http_client.HTTPResponse(FakeSocket())
        source.begin()
        wrapped = urllib.response.addinfourl(source, source.msg, "http://example.com")
        stream = HTMLInputStream(wrapped)
        self.assertEqual(stream.charsUntil(" "), "Text")
开发者ID:MaloChevillotte,项目名称:html5lib-python,代码行数:19,代码来源:test_stream.py

示例5: test_newlines2

# 需要导入模块: from html5lib.inputstream import HTMLInputStream [as 别名]
# 或者: from html5lib.inputstream.HTMLInputStream import charsUntil [as 别名]
 def test_newlines2(self):
     size = HTMLUnicodeInputStream._defaultChunkSize
     stream = HTMLInputStream("\r" * size + "\n")
     self.assertEqual(stream.charsUntil('x'), "\n" * size)
开发者ID:MaloChevillotte,项目名称:html5lib-python,代码行数:6,代码来源:test_stream.py

示例6: test_utf_16

# 需要导入模块: from html5lib.inputstream import HTMLInputStream [as 别名]
# 或者: from html5lib.inputstream.HTMLInputStream import charsUntil [as 别名]
 def test_utf_16(self):
     stream = HTMLInputStream((' ' * 1025).encode('utf-16'))
     self.assertTrue(stream.charEncoding[0] in ['utf-16-le', 'utf-16-be'], stream.charEncoding)
     self.assertEqual(len(stream.charsUntil(' ', True)), 1025)
开发者ID:MaloChevillotte,项目名称:html5lib-python,代码行数:6,代码来源:test_stream.py

示例7: test_newlines2

# 需要导入模块: from html5lib.inputstream import HTMLInputStream [as 别名]
# 或者: from html5lib.inputstream.HTMLInputStream import charsUntil [as 别名]
def test_newlines2():
    size = HTMLUnicodeInputStream._defaultChunkSize
    stream = HTMLInputStream("\r" * size + "\n")
    assert stream.charsUntil('x') == "\n" * size
开发者ID:adamchainz,项目名称:html5lib-python,代码行数:6,代码来源:test_stream.py

示例8: test_utf_16

# 需要导入模块: from html5lib.inputstream import HTMLInputStream [as 别名]
# 或者: from html5lib.inputstream.HTMLInputStream import charsUntil [as 别名]
def test_utf_16():
    stream = HTMLInputStream((' ' * 1025).encode('utf-16'))
    assert stream.charEncoding[0].name in ['utf-16le', 'utf-16be']
    assert len(stream.charsUntil(' ', True)) == 1025
开发者ID:adamchainz,项目名称:html5lib-python,代码行数:6,代码来源:test_stream.py


注:本文中的html5lib.inputstream.HTMLInputStream.charsUntil方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。