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


Python escape.xhtml_unescape方法代码示例

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


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

示例1: test_xhtml_escape

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import xhtml_unescape [as 别名]
def test_xhtml_escape(self):
        tests = [
            ("<foo>", "&lt;foo&gt;"),
            (u("<foo>"), u("&lt;foo&gt;")),
            (b"<foo>", b"&lt;foo&gt;"),

            ("<>&\"'", "&lt;&gt;&amp;&quot;&#39;"),
            ("&amp;", "&amp;amp;"),

            (u("<\u00e9>"), u("&lt;\u00e9&gt;")),
            (b"<\xc3\xa9>", b"&lt;\xc3\xa9&gt;"),
        ]
        for unescaped, escaped in tests:
            self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped))
            self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped))) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:17,代码来源:escape_test.py

示例2: test_xhtml_unescape_numeric

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import xhtml_unescape [as 别名]
def test_xhtml_unescape_numeric(self):
        tests = [
            ('foo&#32;bar', 'foo bar'),
            ('foo&#x20;bar', 'foo bar'),
            ('foo&#X20;bar', 'foo bar'),
            ('foo&#xabc;bar', u('foo\u0abcbar')),
            ('foo&#xyz;bar', 'foo&#xyz;bar'),  # invalid encoding
            ('foo&#;bar', 'foo&#;bar'),        # invalid encoding
            ('foo&#x;bar', 'foo&#x;bar'),      # invalid encoding
        ]
        for escaped, unescaped in tests:
            self.assertEqual(unescaped, xhtml_unescape(escaped)) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:14,代码来源:escape_test.py

示例3: parse_cases

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import xhtml_unescape [as 别名]
def parse_cases(filename):
  """Parses the fogbugz data in the file.

  Returns a list of (subject, assigned_to, body) tuples.
  """
  results = []

  tree = ElementTree.parse(filename)

  for case in tree.find('cases').findall('case'):
    subject = 'FB%s: %s' % (case.get('ixBug'), case.findtext('sTitle'))
    body = []
    assigned_to = case.findtext('sPersonAssignedTo')
    body.append('Assigned to: %s' % assigned_to)
    body.append('Project: %s' % case.findtext('sProject'))
    body.append('Area: %s' % case.findtext('sArea'))
    body.append('Priority: %s (%s)' % (case.findtext('ixPriority'), case.findtext('sPriority')))
    body.append('Category: %s' % case.findtext('sCategory'))
    body.append('')
    for event in case.find('events').findall('event'):
      body.append( '%s at %s' % (event.findtext('evtDescription'), event.findtext('dt')))
      if event.findtext('s'):
        body.append('')
        body.append(event.findtext('s'))
        body.append('')
      if event.find('rgAttachments') is not None:
        for attachment in event.find('rgAttachments').findall('attachment'):
          body.append('Attachment: %s' % escape.xhtml_unescape(attachment.findtext('sURL')))
    results.append((subject, USER_MAP[assigned_to], '\n'.join(body)))
  return results 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:32,代码来源:parse_cases.py

示例4: test_xhtml_escape

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import xhtml_unescape [as 别名]
def test_xhtml_escape(self):
        tests = [
            ("<foo>", "&lt;foo&gt;"),
            (u"<foo>", u"&lt;foo&gt;"),
            (b("<foo>"), b("&lt;foo&gt;")),

            ("<>&\"", "&lt;&gt;&amp;&quot;"),
            ("&amp;", "&amp;amp;"),
            ]
        for unescaped, escaped in tests:
            self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped))
            self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped))) 
开发者ID:omererdem,项目名称:honeything,代码行数:14,代码来源:escape_test.py


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