jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/630595 )

Change subject: [cleanup] remove desupported setAction method
......................................................................

[cleanup] remove desupported setAction method

Change-Id: I324551feeb5c78e99504b7b88cad6939f858c279
---
M pywikibot/__init__.py
M scripts/checkimages.py
M tests/dry_site_tests.py
3 files changed, 31 insertions(+), 50 deletions(-)

Approvals:
  Hazard-SJ: Looks good to me, but someone else must approve
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index df21568..a988141 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -57,9 +57,7 @@
 from pywikibot.site import BaseSite
 import pywikibot.textlib as textlib
 from pywikibot.tools import (
-    # __ to avoid conflict with ModuleDeprecationWrapper._deprecated
     classproperty,
-    deprecated as __deprecated,
     deprecate_arg as _deprecate_arg,
     issue_deprecation_warning,
     normalize_username,
@@ -1274,13 +1272,6 @@
 link_regex = re.compile(r'\[\[(?P<title>[^\]|[<>{}]*)(\|.*?)?\]\]')


-@__deprecated('comment parameter for page saving method', since='20140604',
-              future_warning=True)
-def setAction(s):
-    """Set a summary to use for changed page submissions."""
-    config.default_edit_summary = s
-
-
 def showDiff(oldtext, newtext, context=0):
     """
     Output a string showing the differences between oldtext and newtext.
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 1d612fa..84a8adb 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -92,6 +92,7 @@
 import pywikibot

 from pywikibot.bot import suggest_help
+from pywikibot import config2 as config
 from pywikibot.exceptions import NotEmailableError
 from pywikibot.family import Family
 from pywikibot import i18n
@@ -591,6 +592,7 @@
         except pywikibot.NoPage:
             pywikibot.output(self.imageName + ' has been deleted...')
             return False
+
         # You can use this function also to find only the user that
         # has upload the image (FixME: Rewrite a bit this part)
         if put:
@@ -603,6 +605,7 @@
             except pywikibot.LockedPage:
                 pywikibot.output('File is locked. Skipping.')
                 return False
+
         # paginetta it's the image page object.
         try:
             if reportPageObject == self.image and self.uploader:
@@ -617,6 +620,7 @@
             self.report_image(self.image_to_report, self.rep_page, self.com,
                               repme)
             return False
+
         upBots = i18n.translate(self.site, uploadBots)
         user = pywikibot.User(self.site, nick)
         luser = user.title(as_url=True)
@@ -641,6 +645,7 @@
         else:
             self.notification2 = self.notification
         second_text = False
+
         # Getting the talk page's history, to check if there is another
         # advise...
         try:
@@ -669,6 +674,7 @@
             pywikibot.output('The user page is blank')
             second_text = False
             testoattuale = i18n.translate(self.site, empty)
+
         if self.commTalk:
             commentox = self.commTalk
         else:
@@ -677,8 +683,8 @@
         if second_text:
             newText = '{}\n\n{}'.format(testoattuale, self.notification2)
         else:
-            newText = '{0}\n\n== {1} ==\n{2}'.format(testoattuale, self.head,
-                                                     self.notification)
+            newText = '{}\n\n== {} ==\n{}'.format(testoattuale, self.head,
+                                                  self.notification)

         # Check maximum number of notifications for this talk page
         if (self.num_notify is not None
@@ -1446,11 +1452,13 @@
             pywikibot.output("Skipping {} because it's a redirect."
                              .format(self.imageName))
             return
+
         # Delete the fields where the templates cannot be loaded
         regex_nowiki = re.compile(r'<nowiki>(.*?)</nowiki>', re.DOTALL)
         regex_pre = re.compile(r'<pre>(.*?)</pre>', re.DOTALL)
         self.imageCheckText = regex_nowiki.sub('', self.imageCheckText)
         self.imageCheckText = regex_pre.sub('', self.imageCheckText)
+
         # Deleting the useless template from the description (before adding
         # sth in the image the original text will be reloaded, don't worry).
         if self.isTagged():
@@ -1462,31 +1470,39 @@
             if a_word in self.imageCheckText:
                 # There's a template, probably a license
                 brackets = True
+
         # Is the extension allowed? (is it an image or f.e. a .xls file?)
         if allowed_formats and extension.lower() not in allowed_formats:
             delete = True
+
         (license_found, hiddenTemplateFound) = self.smartDetection()
+
         # Here begins the check block.
         if brackets and license_found:
             return
-        elif delete:
+
+        if delete:
             pywikibot.output('{} is not a file!'.format(self.imageName))
             if not di:
                 pywikibot.output('No localized message given for '
                                  "'delete_immediately'. Skipping.")
                 return
+
             # Some formatting for delete immediately template
             dels = dels % {'adding': di}
             di = '\n' + di
+
             # Modify summary text
-            pywikibot.setAction(dels)
+            config.default_edit_summary = dels
+
             canctext = di % extension
             notification = din % {'file': self.image.title(as_link=True,
                                                            textlink=True)}
             head = dih
             self.report(canctext, self.imageName, notification, head)
             return
-        elif not self.imageCheckText.strip():  # empty image description
+
+        if not self.imageCheckText.strip():  # empty image description
             pywikibot.output(
                 "The file's description for {} does not contain a license "
                 ' template!'.format(self.imageName))
@@ -1498,17 +1514,15 @@
             self.report(self.unvertext, self.imageName, notification, head,
                         smwl)
             return
-        else:
-            pywikibot.output('{} has only text and not the specific '
-                             'license...'.format(self.imageName))
-            if hiddenTemplateFound and HiddenTN:
-                notification = HiddenTN % self.imageName
-            elif nn:
-                notification = nn % self.imageName
-            head = nh
-            self.report(self.unvertext, self.imageName, notification, head,
-                        smwl)
-            return
+
+        pywikibot.output('{} has only text and not the specific '
+                         'license...'.format(self.imageName))
+        if hiddenTemplateFound and HiddenTN:
+            notification = HiddenTN % self.imageName
+        elif nn:
+            notification = nn % self.imageName
+        head = nh
+        self.report(self.unvertext, self.imageName, notification, head, smwl)


 def main(*args) -> bool:
diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py
index dd3434a..2a71321 100644
--- a/tests/dry_site_tests.py
+++ b/tests/dry_site_tests.py
@@ -9,7 +9,7 @@

 from pywikibot.comms.http import user_agent

-from tests.aspects import unittest, DefaultDrySiteTestCase, DeprecationTestCase
+from tests.aspects import unittest, DefaultDrySiteTestCase


 class TestDrySite(DefaultDrySiteTestCase):
@@ -107,29 +107,5 @@
                                     format_string='Foo ({script_comments})'))


-class TestSetAction(DeprecationTestCase):
-
-    """Test the deprecated setAction function."""
-
-    net = False
-
-    def setUp(self):
-        """Backup the original configuration."""
-        super().setUp()
-        self._old_config = pywikibot.config.default_edit_summary
-
-    def tearDown(self):
-        """Restore the original configuration."""
-        pywikibot.config.default_edit_summary = self._old_config
-        super().tearDown()
-
-    def test_set_action(self):
-        """Test deprecated setAction function."""
-        pywikibot.setAction('{0}X{0}'.format(self._old_config))
-        self.assertOneDeprecation(self.INSTEAD)
-        self.assertEqual(pywikibot.config.default_edit_summary,
-                         '{0}X{0}'.format(self._old_config))
-
-
 if __name__ == '__main__':  # pragma: no cover
     unittest.main()

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/630595
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I324551feeb5c78e99504b7b88cad6939f858c279
Gerrit-Change-Number: 630595
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Hazard-SJ <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to