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


Python Stream.render方法代码示例

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


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

示例1: extract_javascript_script

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
    def extract_javascript_script(fileobj, keywords, comment_tags, options):
        """Extract messages from Javascript embedding in <script> tags.

        Select <script type="javascript/text"> tags and delegate to
        `extract_javascript`.
        """
        from genshi.core import Stream
        from genshi.input import XMLParser

        out = StringIO()
        stream = Stream(XMLParser(fileobj))
        stream = stream.select('//script[@type="text/javascript"]')
        stream.render(out=out, encoding='utf-8')
        out.seek(0)
        return extract_javascript(out, keywords, comment_tags, options)
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:17,代码来源:dist.py

示例2: test_doctype_in_stream_no_sysid

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_doctype_in_stream_no_sysid(self):
     stream = Stream([(Stream.DOCTYPE,
                      ('html', '-//W3C//DTD HTML 4.01//EN', None),
                      (None, -1, -1))])
     output = stream.render(XMLSerializer, encoding=None)
     self.assertEqual('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">\n',
                      output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:9,代码来源:output.py

示例3: test_doctype_in_stream

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_doctype_in_stream(self):
     stream = Stream([(Stream.DOCTYPE, DocType.HTML_STRICT, (None, -1, -1))])
     output = stream.render(XMLSerializer, encoding=None)
     self.assertEqual('<!DOCTYPE html PUBLIC '
                      '"-//W3C//DTD HTML 4.01//EN" '
                      '"http://www.w3.org/TR/html4/strict.dtd">\n',
                      output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:9,代码来源:output.py

示例4: test_xml_decl_dropped

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_xml_decl_dropped(self):
     stream = Stream([(Stream.XML_DECL, ('1.0', None, -1), (None, -1, -1))])
     output = stream.render(XHTMLSerializer, doctype='xhtml', encoding=None)
     self.assertEqual('<!DOCTYPE html PUBLIC '
                      '"-//W3C//DTD XHTML 1.0 Strict//EN" '
                      '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n',
                      output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:9,代码来源:output.py

示例5: test_serializer_doctype

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_serializer_doctype(self):
     stream = Stream([])
     output = stream.render(XMLSerializer, doctype=DocType.HTML_STRICT)
     self.assertEqual('<!DOCTYPE html PUBLIC '
                      '"-//W3C//DTD HTML 4.01//EN" '
                      '"http://www.w3.org/TR/html4/strict.dtd">\n',
                      output)
开发者ID:alon,项目名称:polinax,代码行数:9,代码来源:output.py

示例6: test_with_xml_decl

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_with_xml_decl(self):
     stream = Stream([(Stream.XML_DECL, ('1.0', None, -1), (None, -1, -1))])
     output = stream.render(XMLSerializer, doctype='xhtml')
     self.assertEqual('<?xml version="1.0"?>\n'
                      '<!DOCTYPE html PUBLIC '
                      '"-//W3C//DTD XHTML 1.0 Strict//EN" '
                      '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n',
                      output)
开发者ID:alon,项目名称:polinax,代码行数:10,代码来源:output.py

示例7: test_doctype_one_and_only

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_doctype_one_and_only(self):
     stream = Stream([
         (Stream.DOCTYPE, ('html', None, None), (None, -1, -1))
     ])
     output = stream.render(XMLSerializer, doctype=DocType.HTML_STRICT)
     self.assertEqual('<!DOCTYPE html PUBLIC '
                      '"-//W3C//DTD HTML 4.01//EN" '
                      '"http://www.w3.org/TR/html4/strict.dtd">\n',
                      output)
开发者ID:alon,项目名称:polinax,代码行数:11,代码来源:output.py

示例8: test_doctype_in_stream_no_pubid

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_doctype_in_stream_no_pubid(self):
     stream = Stream([
         (Stream.DOCTYPE,
          ('html', None, 'http://www.w3.org/TR/html4/strict.dtd'),
          (None, -1, -1))
     ])
     output = stream.render(XMLSerializer, encoding=None)
     self.assertEqual('<!DOCTYPE html SYSTEM '
                      '"http://www.w3.org/TR/html4/strict.dtd">\n',
                      output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:12,代码来源:output.py

示例9: test_cache_markup

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_cache_markup(self):
     loc = (None, -1, -1)
     stream = Stream([(Stream.START, (QName('foo'), Attrs()), loc),
                      (Stream.TEXT, u'&hellip;', loc),
                      (Stream.END, QName('foo'), loc),
                      (Stream.START, (QName('bar'), Attrs()), loc),
                      (Stream.TEXT, Markup('&hellip;'), loc),
                      (Stream.END, QName('bar'), loc)])
     output = stream.render(XMLSerializer, encoding=None, 
                            strip_whitespace=False)
     self.assertEqual('<foo>&amp;hellip;</foo><bar>&hellip;</bar>', output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:13,代码来源:output.py

示例10: test_multiple_bound_namespaces

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_multiple_bound_namespaces(self):
     stream = Stream([
         (Stream.START, (QName('div'), Attrs()), (None, -1, -1)),
         (Stream.TEXT, '\n          ', (None, -1, -1)),
         (Stream.START_NS, ('x', 'http://example.org/'), (None, -1, -1)),
         (Stream.START, (QName('http://example.org/}p'), Attrs()), (None, -1, -1)),
         (Stream.END, QName('http://example.org/}p'), (None, -1, -1)),
         (Stream.END_NS, 'x', (None, -1, -1)),
         (Stream.TEXT, '\n          ', (None, -1, -1)),
         (Stream.START_NS, ('x', 'http://example.org/'), (None, -1, -1)),
         (Stream.START, (QName('http://example.org/}p'), Attrs()), (None, -1, -1)),
         (Stream.END, QName('http://example.org/}p'), (None, -1, -1)),
         (Stream.END_NS, 'x', (None, -1, -1)),
         (Stream.TEXT, '\n        ', (None, -1, -1)),
         (Stream.END, QName('div'), (None, -1, -1)),
     ])
     output = stream.render(XMLSerializer, encoding=None)
     self.assertEqual("""<div>
       <x:p xmlns:x="http://example.org/"/>
       <x:p xmlns:x="http://example.org/"/>
     </div>""", output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:23,代码来源:output.py

示例11: test_nested_default_namespaces

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_nested_default_namespaces(self):
     stream = Stream([
         (Stream.START_NS, ('', 'http://example.org/'), (None, -1, -1)),
         (Stream.START, (QName('http://example.org/}div'), Attrs()), (None, -1, -1)),
         (Stream.TEXT, '\n          ', (None, -1, -1)),
         (Stream.START_NS, ('', 'http://example.org/'), (None, -1, -1)),
         (Stream.START, (QName('http://example.org/}p'), Attrs()), (None, -1, -1)),
         (Stream.END, QName('http://example.org/}p'), (None, -1, -1)),
         (Stream.END_NS, '', (None, -1, -1)),
         (Stream.TEXT, '\n          ', (None, -1, -1)),
         (Stream.START_NS, ('', 'http://example.org/'), (None, -1, -1)),
         (Stream.START, (QName('http://example.org/}p'), Attrs()), (None, -1, -1)),
         (Stream.END, QName('http://example.org/}p'), (None, -1, -1)),
         (Stream.END_NS, '', (None, -1, -1)),
         (Stream.TEXT, '\n        ', (None, -1, -1)),
         (Stream.END, QName('http://example.org/}div'), (None, -1, -1)),
         (Stream.END_NS, '', (None, -1, -1))
     ])
     output = stream.render(XMLSerializer, encoding=None)
     self.assertEqual("""<div xmlns="http://example.org/">
       <p/>
       <p/>
     </div>""", output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:25,代码来源:output.py

示例12: test_nested_bound_namespaces

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_nested_bound_namespaces(self):
     stream = Stream([
         (Stream.START_NS, ('x', 'http://example.org/'), (None, -1, -1)),
         (Stream.START, (QName('div'), Attrs()), (None, -1, -1)),
         (Stream.TEXT, '\n          ', (None, -1, -1)),
         (Stream.START_NS, ('x', 'http://example.org/'), (None, -1, -1)),
         (Stream.START, (QName('p'), Attrs()), (None, -1, -1)),
         (Stream.END, QName('p'), (None, -1, -1)),
         (Stream.END_NS, 'x', (None, -1, -1)),
         (Stream.TEXT, '\n          ', (None, -1, -1)),
         (Stream.START_NS, ('x', 'http://example.org/'), (None, -1, -1)),
         (Stream.START, (QName('p'), Attrs()), (None, -1, -1)),
         (Stream.END, QName('p'), (None, -1, -1)),
         (Stream.END_NS, 'x', (None, -1, -1)),
         (Stream.TEXT, '\n        ', (None, -1, -1)),
         (Stream.END, QName('div'), (None, -1, -1)),
         (Stream.END_NS, 'x', (None, -1, -1))
     ])
     output = stream.render(XHTMLSerializer)
     self.assertEqual("""<div xmlns:x="http://example.org/">
       <p></p>
       <p></p>
     </div>""", output)
开发者ID:alon,项目名称:polinax,代码行数:25,代码来源:output.py

示例13: test_processing_instruction

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_processing_instruction(self):
     stream = Stream([(Stream.PI, ('python', 'x = 2'), (None, -1, -1))])
     output = stream.render(XMLSerializer, encoding=None)
     self.assertEqual('<?python x = 2?>', output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:6,代码来源:output.py

示例14: test_comment

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_comment(self):
     stream = Stream([(Stream.COMMENT, 'foo bar', (None, -1, -1))])
     output = stream.render(XMLSerializer, encoding=None)
     self.assertEqual('<!--foo bar-->', output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:6,代码来源:output.py

示例15: test_doctype_in_stream_no_pubid_or_sysid

# 需要导入模块: from genshi.core import Stream [as 别名]
# 或者: from genshi.core.Stream import render [as 别名]
 def test_doctype_in_stream_no_pubid_or_sysid(self):
     stream = Stream([(Stream.DOCTYPE, ('html', None, None),
                      (None, -1, -1))])
     output = stream.render(XMLSerializer, encoding=None)
     self.assertEqual('<!DOCTYPE html>\n', output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:7,代码来源:output.py


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