本文整理汇总了Python中pywikibot.proofreadpage.ProofreadPage类的典型用法代码示例。如果您正苦于以下问题:Python ProofreadPage类的具体用法?Python ProofreadPage怎么用?Python ProofreadPage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProofreadPage类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_index
def test_index(self):
"""Test index property."""
# Page with Index.
page = ProofreadPage(self.site, self.valid['title'])
index_page = IndexPage(self.site, self.valid['index'])
# Test propery.
self.assertEqual(page.index, index_page)
# Test deleter
del page.index
self.assertFalse(hasattr(page, '_index'))
# Test setter
page.index = index_page
self.assertEqual(page.index, index_page)
# Page without Index.
page = ProofreadPage(self.site, self.existing_multilinked['title'])
index_page_1 = IndexPage(self.site, self.existing_multilinked['index_1'])
index_page_2 = IndexPage(self.site, self.existing_multilinked['index_2'])
self.assertEqual(page.index, index_page_1)
self.assertNotEqual(page.index, index_page_2)
self.assertEqual(page._index, (index_page_1, [index_page_2]))
# Page without Index.
page = ProofreadPage(self.site, self.existing_unlinked['title'])
self.assertIs(page.index, None)
self.assertEqual(page._index, (None, []))
示例2: test_invalid_not_existing_page_source
def test_invalid_not_existing_page_source(self):
"""Test ProofreadPage from invalid not existing Page as source."""
# namespace is forced
source = pywikibot.Page(self.site, self.not_existing_invalid["title"])
fixed_source = pywikibot.Page(self.site, source.title(withNamespace=False), ns=self.site.proofread_page_ns)
page = ProofreadPage(fixed_source)
self.assertEqual(page.title(), fixed_source.title())
示例3: gen
def gen(self):
"""Generate pages from specified page interval."""
for page_number in self.page_number_gen():
title = '{prefix}/{number}'.format(prefix=self._prefix,
number=page_number)
page = ProofreadPage(self._index.site, title)
page.page_number = page_number # remember page number in djvu file
yield page
示例4: test_preload_from_empty_text
def test_preload_from_empty_text(self):
"""Test ProofreadPage page decomposing/composing text."""
page = ProofreadPage(self.site, 'dummy test page')
page.text = ''
self.assertEqual(page.text,
'<noinclude><pagequality level="1" user="" />'
'<div class="pagetext">\n\n\n</noinclude>'
'<noinclude></div></noinclude>')
示例5: test_valid_link_source
def test_valid_link_source(self):
"""Test ProofreadPage from valid Link as source."""
source = pywikibot.Link(
self.valid['title'],
source=self.site,
defaultNamespace=self.site.proofread_page_ns)
page = ProofreadPage(source)
self.assertEqual(page.title(withNamespace=False), source.title)
self.assertEqual(page.namespace(), source.namespace)
示例6: test_preload_from_empty_text
def test_preload_from_empty_text(self):
"""Test ProofreadPage page decomposing/composing text."""
page = ProofreadPage(self.site, 'Page:dummy test page')
page.text = ''
class_pagetext, div = self.class_pagetext_fmt[page._full_header._has_div]
self.assertEqual(page.text,
self.fmt.format(user=self.site.username(),
class_pagetext=class_pagetext,
references='',
div_end=div))
示例7: test_json_format
def test_json_format(self):
"""Test conversion to json format."""
page = ProofreadPage(self.site, self.valid["title"])
rvargs = {
"rvprop": "ids|flags|timestamp|user|comment|content",
"rvcontentformat": "application/json",
"titles": page,
}
rvgen = self.site._generator(api.PropertyGenerator, type_arg="info|revisions", total=1, **rvargs)
rvgen.set_maximum_items(-1) # suppress use of rvlimit parameter
try:
pagedict = next(iter(rvgen))
loaded_text = pagedict.get("revisions")[0].get("*")
except (StopIteration, TypeError, KeyError, ValueError, IndexError):
page_text = ""
page_text = page._page_to_json()
self.assertEqual(json.loads(page_text), json.loads(loaded_text))
示例8: test_valid_site_source
def test_valid_site_source(self):
"""Test ProofreadPage from valid Site as source."""
page = ProofreadPage(self.site, 'Page:dummy test page')
self.assertEqual(page.namespace(), self.site.proofread_page_ns)