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


Python core.Stream类代码示例

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


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

示例1: test_doctype_in_stream

 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,代码行数:7,代码来源:output.py

示例2: test_doctype_in_stream_no_sysid

 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,代码行数:7,代码来源:output.py

示例3: test_serializer_doctype

 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,代码行数:7,代码来源:output.py

示例4: helper

 def helper(field_stream):
     s =  Stream(field_stream)
     f = s.select('//strong/text()').textOf()
     if field != f: #if we are the field just skip it
         #identity stream filter
         for kind, data, pos in s:
             yield kind, data, pos
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:7,代码来源:blackmagic.py

示例5: test_xml_decl_dropped

 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,代码行数:7,代码来源:output.py

示例6: test_with_xml_decl

 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,代码行数:8,代码来源:output.py

示例7: test_doctype_one_and_only

 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,代码行数:9,代码来源:output.py

示例8: test_doctype_in_stream_no_pubid

 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,代码行数:10,代码来源:output.py

示例9: test_cache_markup

 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,代码行数:11,代码来源:output.py

示例10: extract_javascript_script

    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.select('//script[@type="text/javascript"]').render(out=out)
        out.seek(0)
        return extract_javascript(out, keywords, comment_tags, options)
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:14,代码来源:dist.py

示例11: helper

 def helper(field_stream):
     try:
         s = Stream(field_stream)
         self.log.debug('ChangeLog Pre')
         # without None as the second value we get str instead of unicode
         # and that causes things to break sometimes
         f = s.select('//strong/text()').textOf(strip_markup=True).lower()
         # self.log.debug(u'ChangeLog Pre 2 : %s: %r', type(f), f)
         self.log.debug('ChangeLog Filter: field:%s, label:%s, we are looking at:%r, skip?%s',
                        field, check, f, check == f )
         if check != f: #if we are the field just skip it
         #identity stream filter
             for kind, data, pos in s:
                 yield kind, data, pos
     except Exception, e:
         self.log.exception('ChangeLog: Stream Filter Exception');
         raise e
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:17,代码来源:blackmagic.py

示例12: setUp

 def setUp(self):
     env = EnvironmentStub(enable=[Chrome, PatchRenderer])
     req = Mock(base_path='', chrome={'static_hash': None}, args={},
                session={}, abs_href=Href('/'), href=Href('/'), locale='',
                perm=MockPerm(), authname=None, tz=None)
     self.context = web_context(req)
     self.patch = Mimeview(env).renderers[0]
     patch_html = open(os.path.join(os.path.split(__file__)[0],
                                    'patch.html'))
     self.patch_html = Stream(list(HTMLParser(patch_html, encoding='utf-8')))
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:10,代码来源:patch.py

示例13: setUp

 def setUp(self):
     env = EnvironmentStub(enable=[Chrome, PatchRenderer])
     req = Mock(base_path='', chrome={}, args={}, session={},
                abs_href=Href('/'), href=Href('/'),
                perm=MockPerm(), authname=None, tz=None)
     self.context = Context.from_request(req)
     self.patch = Mimeview(env).renderers[0]
     patch_html = open(os.path.join(os.path.split(__file__)[0],
                                    'patch.html'))
     self.patch_html = Stream(list(HTMLParser(patch_html)))
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:10,代码来源:patch.py

示例14: setUp

 def setUp(self):
     self.env = EnvironmentStub(enable=[Chrome, PygmentsRenderer])
     self.pygments = Mimeview(self.env).renderers[0]
     self.req = Mock(base_path='', chrome={}, args={},
                     abs_href=Href('/'), href=Href('/'),
                     session={}, perm=None, authname=None, tz=None)
     self.context = web_context(self.req)
     pygments_html = open(os.path.join(os.path.split(__file__)[0],
                                    'pygments.html'))
     self.pygments_html = Stream(list(HTMLParser(pygments_html, encoding='utf-8')))
开发者ID:exocad,项目名称:exotrac,代码行数:10,代码来源:pygments.py

示例15: test_multiple_bound_namespaces

 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,代码行数:21,代码来源:output.py


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