コード例 #1
0
 def test_category_format_Page(self):
     data = [
         pywikibot.Page(self.site, 'Category:Cat1'),
         pywikibot.Page(self.site, 'Category:Cat2')
     ]
     self.assertEqual(self.catresult,
                      textlib.categoryFormat(data, self.site))
コード例 #2
0
ファイル: textlib_tests.py プロジェクト: MKaras93/pywikibot
 def test_category_format_Page(self):
     """Test formatting categories as Page instances."""
     data = [
         pywikibot.Page(self.site, 'Category:Cat1'),
         pywikibot.Page(self.site, 'Category:Cat2')
     ]
     self.assertEqual(self.catresult,
                      textlib.categoryFormat(data, self.site))
コード例 #3
0
    def handle_single_page(self):
        """
        Determine action to perform on page.

        Effectively this is done by setting self.text if an update is
        needed/possible.
        @todo: handle Unresolved better

        :return: String describing action
        """
        log_entry = None
        # determine action
        if self.content_not_changed():
            return "No change from original"  # no need to do an update
        elif self.has_only_one_revision():
            self.text = self.new_text  # just replace contents
            return "One revision"
        elif self.only_cats_differ():
            log_entry = "Only categories"
            final_cats = self.get_final_categories()
            # replace cats in new_text with final cats
            self.text = "{text}\n\n{catgories}".format(
                text=self.remove_cats_and_comments(self.new_text),
                catgories=textlib.categoryFormat(final_cats))
        else:
            # This will also catch any already updated pages
            log_entry = "Unresolved"
            pass  # don't know what to do

        if self.text and self.text == self.page.text or \
                self.new_text == self.page.text:
            # Either by coincidence or due to a previous run
            self.text = None
            return "No change from final version"
        else:
            return log_entry
コード例 #4
0
    def handle_single_page(self):
        """
        Determine action to perform on page.

        Effectively this is done by setting self.text if an update is
        needed/possible.
        @todo: handle Unresolved better

        :return: String describing action
        """
        log_entry = None
        # determine action
        if self.content_not_changed():
            return "No change from original"  # no need to do an update
        elif self.has_only_one_revision():
            self.text = self.new_text  # just replace contents
            return "One revision"
        elif self.only_cats_differ():
            log_entry = "Only categories"
            final_cats = self.get_final_categories()
            # replace cats in new_text with final cats
            self.text = "{text}\n\n{catgories}".format(
                text=self.remove_cats_and_comments(self.new_text),
                catgories=textlib.categoryFormat(final_cats))
        else:
            # This will also catch any already updated pages
            log_entry = "Unresolved"
            pass  # don't know what to do

        if self.text and self.text == self.page.text or \
                self.new_text == self.page.text:
            # Either by coincidence or due to a previous run
            self.text = None
            return "No change from final version"
        else:
            return log_entry
コード例 #5
0
ファイル: textlib_tests.py プロジェクト: metakgp/batman
 def test_category_format_Page(self):
     """Test formatting categories as Page instances."""
     data = [pywikibot.Page(self.site, 'Category:Cat1'),
             pywikibot.Page(self.site, 'Category:Cat2')]
     self.assertEqual(self.catresult,
                      textlib.categoryFormat(data, self.site))
コード例 #6
0
ファイル: textlib_tests.py プロジェクト: metakgp/batman
 def test_category_format_bare(self):
     """Test formatting categories as strings."""
     self.assertEqual(self.catresult,
                      textlib.categoryFormat(['Cat1', 'Cat2'], self.site))
コード例 #7
0
ファイル: textlib_tests.py プロジェクト: metakgp/batman
 def test_category_format_raw(self):
     """Test formatting categories as strings formatted as links."""
     self.assertEqual(self.catresult,
                      textlib.categoryFormat(['[[Category:Cat1]]',
                                              '[[Category:Cat2]]'],
                                             self.site))
コード例 #8
0
 def test_category_format_Page(self):
     data = [pywikibot.Page(self.site, "Category:Cat1"), pywikibot.Page(self.site, "Category:Cat2")]
     self.assertEqual(self.catresult, textlib.categoryFormat(data, self.site))
コード例 #9
0
 def test_category_format_bare(self):
     self.assertEqual(self.catresult, textlib.categoryFormat(["Cat1", "Cat2"], self.site))
コード例 #10
0
ファイル: textlib_tests.py プロジェクト: MKaras93/pywikibot
 def test_category_format_bare(self):
     """Test formatting categories as strings."""
     self.assertEqual(self.catresult,
                      textlib.categoryFormat(['Cat1', 'Cat2'], self.site))
コード例 #11
0
 def test_category_format_bare(self):
     self.assertEqual(self.catresult,
                      textlib.categoryFormat(['Cat1', 'Cat2'], self.site))
コード例 #12
0
ファイル: test_textlib.py プロジェクト: moleculea/ess
 def test_categoryFormat_Category(self):
     self.assertEqual(self.catresult1,
                      textlib.categoryFormat(self.data, self.site))
コード例 #13
0
 def test_categoryFormat_bare(self):
     self.assertEqual(self.catresult1,
                      textlib.categoryFormat(['Cat1', 'Cat2'], self.site))
コード例 #14
0
 def test_categoryFormat_raw(self):
     self.assertEqual(self.catresult1,
                      textlib.categoryFormat(['[[Category:Cat1]]',
                                              '[[Category:Cat2]]'],
                                             self.site))
コード例 #15
0
ファイル: textlib_tests.py プロジェクト: xZise/pywikibot-core
 def test_category_format_Category(self):
     data = [pywikibot.Category(self.site, 'Cat1'),
             pywikibot.Category(self.site, 'Cat2')]
     self.assertEqual(self.catresult,
                      textlib.categoryFormat(data, self.site))
コード例 #16
0
 def test_category_format_raw(self):
     self.assertEqual(
         self.catresult,
         textlib.categoryFormat(['[[Category:Cat1]]', '[[Category:Cat2]]'],
                                self.site))
コード例 #17
0
 def test_categoryFormat_Page(self):
     data = [pywikibot.Page(self.site, 'Category:Cat1'),
             pywikibot.Page(self.site, 'Category:Cat2')]
     self.assertEqual(self.catresult1, textlib.categoryFormat(self.data,
                                                           self.site))
コード例 #18
0
 def test_category_format_raw(self):
     self.assertEqual(self.catresult, textlib.categoryFormat(["[[Category:Cat1]]", "[[Category:Cat2]]"], self.site))
コード例 #19
0
ファイル: textlib_tests.py プロジェクト: MKaras93/pywikibot
 def test_category_format_raw(self):
     """Test formatting categories as strings formatted as links."""
     self.assertEqual(
         self.catresult,
         textlib.categoryFormat(['[[Category:Cat1]]', '[[Category:Cat2]]'],
                                self.site))