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


Python input.XML类代码示例

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


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

示例1: test_pickle

 def test_pickle(self):
     xml = XML('<li>Foo</li>')
     buf = StringIO()
     pickle.dump(xml, buf, 2)
     buf.seek(0)
     xml = pickle.load(buf)
     self.assertEquals('<li>Foo</li>', xml.render())
开发者ID:alon,项目名称:polinax,代码行数:7,代码来源:core.py

示例2: test_pickle

 def test_pickle(self):
     xml = XML('<li>Foo</li>')
     buf = BytesIO()
     pickle.dump(xml, buf, 2)
     buf.seek(0)
     xml = pickle.load(buf)
     self.assertEquals('<li>Foo</li>', xml.render(encoding=None))
开发者ID:292388900,项目名称:OmniMarkupPreviewer,代码行数:7,代码来源:core.py

示例3: _test

 def _test(self, expected_id, result):
     expected = self._expected(expected_id).render(encoding='utf-8')
     result = XML(result.render(encoding='utf-8')).render(encoding='utf-8')
     expected, result = expected.splitlines(), result.splitlines()
     for exp, res in zip(expected, result):
         self.assertEquals(exp, res)
     self.assertEquals(len(expected), len(result))
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:7,代码来源:patch.py

示例4: list_security_issues

 def list_security_issues(self):
     '''
     Fills in issues and topissues with security issues information.
     '''
     issues = glob.glob('templates/security/PMASA-*')
     issues.sort(key=lambda x: int(x[24:29]) * 100 - int(x[30:]))
     for issue in issues:
         xmldata = XML(open(issue, 'r').read())
         name = os.path.basename(issue)
         self.data['issues'].append({
             'name': name,
             'link': '%ssecurity/%s' % (BASE_URL, self.get_outname(name)),
             'fulllink': '%s%ssecurity/%s' % (
                 SERVER, BASE_URL, self.get_outname(name)
             ),
             'summary': str(xmldata.select(
                 'def[@function="announcement_summary"]/text()'
             )),
             'date': helper.date.DateTime.parse(str(xmldata.select(
                 'def[@function="announcement_date"]/text()'
             ))),
             'cves': str(xmldata.select(
                 'def[@function="announcement_cve"]/text()'
             )).split(' '),
             'versions': str(xmldata.select(
                 'def[@function="announcement_affected"]/text()'
             )),
         })
     self.data['topissues'] = self.data['issues'][:TOP_ISSUES]
开发者ID:anthonyhlcheng,项目名称:website,代码行数:29,代码来源:render.py

示例5: extract_href

 def extract_href(fragment):
   if isinstance(fragment, (Element, Fragment)):
     stream = tag.body(fragment).generate()
   else :
     self.log.debug("Extracting href from %s", fragment)
     stream = XML('<body>%s</body>' % (unicode(fragment),))
   for x in stream.select('a[@href]') :
     if x[0] == 'START' :
        return x[1][1].get('href')
开发者ID:okamototk,项目名称:kanonconductor,代码行数:9,代码来源:theme.py

示例6: generate_sitemap

 def generate_sitemap(self):
     '''
     Generates list of pages with titles.
     '''
     self.data['sitemap'] = []
     self.data['sitemapxml'] = []
     helper.log.dbg('Generating sitemap:')
     for root, dirs, files in os.walk(TEMPLATES):
         if '.svn' in dirs:
             dirs.remove('.svn')  # don't visit .svn directories
         if '.git' in dirs:
             dirs.remove('.git')  # don't visit .git directories
         files.sort()
         root_dir = root[len(TEMPLATES):].strip('/')
         if len(root_dir) > 0:
             root_dir += '/'
         for filename in files:
             name, ext = os.path.splitext(filename)
             if ext != '.tpl' and name[:6] != 'PMASA-':
                 continue
             if name[0] in ['_', '.']:
                 continue
             if filename in ['index.xml.tpl', 'sitemap.xml.tpl', '404.tpl']:
                 continue
             helper.log.dbg('- %s' % filename)
             xmldata = XML(open(os.path.join(root, filename), 'r').read())
             title = str(xmldata.select(
                 'def[@function="page_title"]/text()'
             ))
             title = title.strip()
             if len(title) == 0:
                 title = str(xmldata.select(
                     'def[@function="announcement_id"]/text()'
                 ))
                 title = title.strip()
             if len(title) == 0:
                 title = 'Index'
             link = root_dir + self.get_outname(name)
             sitemap = {
                 'link': link,
                 'loc': '%s%s%s' % (SERVER, BASE_URL, link),
                 'title': title
             }
             if name[:6] != 'PMASA-':
                 self.data['sitemap'].append(sitemap)
             sitemap.update(self.get_sitemap_data(root_dir + name))
             self.data['sitemapxml'].append(sitemap)
     for link in data.sitemap.ENTRIES:
         sitemap = {
             'loc': SERVER + link,
         }
         sitemap.update(self.get_sitemap_data(link))
         self.data['sitemapxml'].append(sitemap)
开发者ID:anthonyhlcheng,项目名称:website,代码行数:53,代码来源:render.py

示例7: test_render_unicode

 def test_render_unicode(self):
     xml = XML('<li>Über uns</li>')
     self.assertEqual(u'<li>Über uns</li>', xml.render(encoding=None))
开发者ID:alon,项目名称:polinax,代码行数:3,代码来源:core.py

示例8: test_pre_whitespace

 def test_pre_whitespace(self):
     content = '\nHey <em>there</em>.  \n\n    I am indented.\n'
     stream = XML('<pre>%s</pre>' % content)
     output = stream.render(HTMLSerializer, encoding=None)
     self.assertEqual('<pre>%s</pre>' % content, output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:5,代码来源:output.py

示例9: test_textarea_whitespace

 def test_textarea_whitespace(self):
     content = '\nHey there.  \n\n    I am indented.\n'
     stream = XML('<textarea name="foo">%s</textarea>' % content)
     output = stream.render(HTMLSerializer, encoding=None)
     self.assertEqual('<textarea name="foo">%s</textarea>' % content, output)
开发者ID:nervatura,项目名称:nerva2py,代码行数:5,代码来源:output.py

示例10: test_render_unicode

 def test_render_unicode(self):
     xml = XML("<li>Über uns</li>")
     self.assertEqual(u"<li>Über uns</li>", xml.render())
     self.assertEqual(u"<li>Über uns</li>", xml.render(encoding=None))
开发者ID:nervatura,项目名称:nerva2py,代码行数:4,代码来源:core.py

示例11: test_render_ascii

 def test_render_ascii(self):
     xml = XML("<li>Über uns</li>")
     self.assertEqual(u"<li>&#220;ber uns</li>".encode("ascii"), xml.render(encoding="ascii"))
开发者ID:nervatura,项目名称:nerva2py,代码行数:3,代码来源:core.py

示例12: test_render_output_stream_unicode

 def test_render_output_stream_unicode(self):
     xml = XML('<li>Über uns</li>')
     strio = StringIO()
     self.assertEqual(None, xml.render(encoding=None, out=strio))
     self.assertEqual(u'<li>Über uns</li>', strio.getvalue())
开发者ID:alon,项目名称:polinax,代码行数:5,代码来源:core.py

示例13: test_render_output_stream_utf8

 def test_render_output_stream_utf8(self):
     xml = XML('<li>Über uns</li>')
     strio = cStringIO()
     self.assertEqual(None, xml.render(out=strio))
     self.assertEqual('<li>Über uns</li>', strio.getvalue())
开发者ID:alon,项目名称:polinax,代码行数:5,代码来源:core.py

示例14: test_render_utf8

 def test_render_utf8(self):
     xml = XML("<li>Über uns</li>")
     self.assertEqual(u"<li>Über uns</li>".encode("utf-8"), xml.render(encoding="utf-8"))
开发者ID:nervatura,项目名称:nerva2py,代码行数:3,代码来源:core.py

示例15: test_render_utf8

 def test_render_utf8(self):
     xml = XML('<li>Über uns</li>')
     self.assertEqual('<li>Über uns</li>', xml.render())
开发者ID:alon,项目名称:polinax,代码行数:3,代码来源:core.py


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