本文整理汇总了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>", "<foo>"),
(u("<foo>"), u("<foo>")),
(b"<foo>", b"<foo>"),
("<>&\"'", "<>&"'"),
("&", "&amp;"),
(u("<\u00e9>"), u("<\u00e9>")),
(b"<\xc3\xa9>", b"<\xc3\xa9>"),
]
for unescaped, escaped in tests:
self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped))
self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))
示例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 bar', 'foo bar'),
('foo bar', 'foo bar'),
('foo bar', 'foo bar'),
('foo઼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))
示例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
示例4: test_xhtml_escape
# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import xhtml_unescape [as 别名]
def test_xhtml_escape(self):
tests = [
("<foo>", "<foo>"),
(u"<foo>", u"<foo>"),
(b("<foo>"), b("<foo>")),
("<>&\"", "<>&""),
("&", "&amp;"),
]
for unescaped, escaped in tests:
self.assertEqual(utf8(xhtml_escape(unescaped)), utf8(escaped))
self.assertEqual(utf8(unescaped), utf8(xhtml_unescape(escaped)))