本文整理汇总了Python中search.clients.WikiClient.excerpt方法的典型用法代码示例。如果您正苦于以下问题:Python WikiClient.excerpt方法的具体用法?Python WikiClient.excerpt怎么用?Python WikiClient.excerpt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search.clients.WikiClient
的用法示例。
在下文中一共展示了WikiClient.excerpt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_utf8_excerpt
# 需要导入模块: from search.clients import WikiClient [as 别名]
# 或者: from search.clients.WikiClient import excerpt [as 别名]
def test_utf8_excerpt(self):
"""Characters should stay in UTF-8."""
wc = WikiClient()
page = Document.objects.get(pk=4)
q = u'fa\xe7on'
excerpt = wc.excerpt(page.html, q)
assert q in excerpt, u'%s not in %s' % (q, excerpt)
示例2: test_unicode_excerpt
# 需要导入模块: from search.clients import WikiClient [as 别名]
# 或者: from search.clients.WikiClient import excerpt [as 别名]
def test_unicode_excerpt(self):
"""Unicode characters in the excerpt should not be a problem."""
wc = WikiClient()
page = Document.objects.get(pk=2)
try:
excerpt = wc.excerpt(page.html, u'\u3068')
render('{{ c }}', {'c': excerpt})
except UnicodeDecodeError:
self.fail('Raised UnicodeDecodeError.')
示例3: test_clean_excerpt
# 需要导入模块: from search.clients import WikiClient [as 别名]
# 或者: from search.clients.WikiClient import excerpt [as 别名]
def test_clean_excerpt(self):
"""SearchClient.excerpt() should not allow disallowed HTML through."""
wc = WikiClient() # Index strips HTML
qc = QuestionsClient() # Index does not strip HTML
input = "test <div>the start of something</div>"
output_strip = "<b>test</b> the start of something"
output_nostrip = "<b>test</b> <div>the start of " "something</div>"
eq_(output_strip, wc.excerpt(input, "test"))
eq_(output_nostrip, qc.excerpt(input, "test"))
示例4: test_unicode_excerpt
# 需要导入模块: from search.clients import WikiClient [as 别名]
# 或者: from search.clients.WikiClient import excerpt [as 别名]
def test_unicode_excerpt(self):
"""Unicode characters in the excerpt should not be a problem."""
wc = WikiClient()
q = 'contribute'
results = wc.query(q)
eq_(1, len(results))
page = WikiPage.objects.get(pk=results[0]['id'])
try:
excerpt = wc.excerpt(page.content, q)
render('{{ c }}', {'c': excerpt})
except UnicodeDecodeError:
self.fail('Raised UnicodeDecodeError.')
示例5: test_none_content_excerpt
# 需要导入模块: from search.clients import WikiClient [as 别名]
# 或者: from search.clients.WikiClient import excerpt [as 别名]
def test_none_content_excerpt(self):
"""SearchClient.excerpt() returns empty string for None type."""
wc = WikiClient()
eq_('', wc.excerpt(None, 'test'))
示例6: test_empty_content_excerpt
# 需要导入模块: from search.clients import WikiClient [as 别名]
# 或者: from search.clients.WikiClient import excerpt [as 别名]
def test_empty_content_excerpt(self):
"""SearchClient.excerpt() returns empty string for empty content."""
wc = WikiClient()
eq_('', wc.excerpt('', 'test'))
示例7: test_clean_excerpt
# 需要导入模块: from search.clients import WikiClient [as 别名]
# 或者: from search.clients.WikiClient import excerpt [as 别名]
def test_clean_excerpt(self):
"""SearchClient.excerpt() should not allow disallowed HTML through."""
wc = WikiClient() # Index strips HTML
input = 'test <div>the start of something</div>'
output_strip = '<b>test</b> the start of something'
eq_(output_strip, wc.excerpt(input, 'test'))
示例8: test_clean_excerpt
# 需要导入模块: from search.clients import WikiClient [as 别名]
# 或者: from search.clients.WikiClient import excerpt [as 别名]
def test_clean_excerpt(self):
"""SearchClient.excerpt() should not allow disallowed HTML through."""
wc = WikiClient()
eq_('<b>test</b></style>', wc.excerpt('test</style>', 'test'))