本文整理匯總了Python中pywikibot.proofreadpage.IndexPage.get_label_from_page方法的典型用法代碼示例。如果您正苦於以下問題:Python IndexPage.get_label_from_page方法的具體用法?Python IndexPage.get_label_from_page怎麽用?Python IndexPage.get_label_from_page使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pywikibot.proofreadpage.IndexPage
的用法示例。
在下文中一共展示了IndexPage.get_label_from_page方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_labels
# 需要導入模塊: from pywikibot.proofreadpage import IndexPage [as 別名]
# 或者: from pywikibot.proofreadpage.IndexPage import get_label_from_page [as 別名]
def test_get_labels(self, key):
"""Test IndexPage page get_label_from_* functions."""
data = self.sites[key]
num, title_num, label = data['get_label']
index_page = IndexPage(self.site, self.sites[key]['index'])
page_title = self.sites[key]['page'].format(title_num)
proofread_page = ProofreadPage(self.site, page_title)
# Get label from number.
self.assertEqual(index_page.get_label_from_page_number(num), label)
# Error if number does not exists.
self.assertRaises(KeyError, index_page.get_label_from_page_number, -1)
# Get label from page.
self.assertEqual(index_page.get_label_from_page(proofread_page), label)
# Error if page does not exists.
self.assertRaises(KeyError, index_page.get_label_from_page, None)
示例2: test_page_number_mapping
# 需要導入模塊: from pywikibot.proofreadpage import IndexPage [as 別名]
# 或者: from pywikibot.proofreadpage.IndexPage import get_label_from_page [as 別名]
def test_page_number_mapping(self, key):
"""Test consistency of page <-> mapping."""
data = self.sites[key]
num, title_num, label = data["get_label"]
index_page = IndexPage(self.site, self.sites[key]["index"])
page_title = self.sites[key]["page"].format(title_num)
proofread_page = ProofreadPage(self.site, page_title)
# Get label from number.
self.assertEqual(index_page.get_label_from_page_number(num), label)
# Error if number does not exists.
self.assertRaises(KeyError, index_page.get_label_from_page_number, -1)
# Get label from page.
self.assertEqual(index_page.get_label_from_page(proofread_page), label)
# Error if page does not exists.
self.assertRaises(KeyError, index_page.get_label_from_page, None)