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

Change subject: [IMPR] use_disambig BaseBot attribute to hande disambig skipping
......................................................................

[IMPR] use_disambig BaseBot attribute to hande disambig skipping

use_disambig attribute is introduced to determine whether to use disambiguation
pages. If set to True to use disambigs only, if set to False to skip disambigs.
If None both are processed.

Change-Id: I244c4a1c40c7337e9a4f35d5708af79b838fa336
---
M pywikibot/bot.py
M scripts/commonscat.py
M scripts/noreferences.py
3 files changed, 21 insertions(+), 12 deletions(-)

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



diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index b70f2f3..98dc354 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1227,6 +1227,14 @@
        The default counters are 'read', 'write' and 'skip'.
     """

+    use_disambigs = None  # type: Optional[bool]
+    """Attribute to determine whether to use disambiguation pages. Set
+    it to True to use disambigs only, set it to False to skip disambigs.
+    If None both are processed.
+
+    .. versionadded:: 7.2
+    """
+
     use_redirects = None  # type: Optional[bool]
     """Attribute to determine whether to use redirect pages. Set it to
     True to use redirects only, set it to False to skip redirects. If
@@ -1527,7 +1535,8 @@
         .. versionadded:: 3.0

         .. versionchanged:: 7.2
-           use :attr:`use_redirects` to handle redirects
+           use :attr:`use_redirects` to handle redirects,
+           use :attr:`use_disambigs` to handle disambigs

         :param page: Page object to be processed
         """
@@ -1539,6 +1548,14 @@
                 .format(page=page, not_='not ' if self.use_redirects else ''))
             return True

+        if isinstance(self.use_disambigs, bool) \
+           and page.isDisambig() is not self.use_disambigs:
+            pywikibot.warning(
+                'Page {page} on {page.site} is skipped because it is {not_}'
+                'a disambig'
+                .format(page=page, not_='not ' if self.use_disambigs else ''))
+            return True
+
         return False

     def treat(self, page: Any) -> None:
diff --git a/scripts/commonscat.py b/scripts/commonscat.py
index 4f4bf22..d2b0915 100755
--- a/scripts/commonscat.py
+++ b/scripts/commonscat.py
@@ -233,21 +233,17 @@
        CommonscatBot is a ConfigParserBot
     """

+    use_disambigs = False
     use_redirects = False
     update_options = {'summary': ''}

     def skip_page(self, page):
-        """Skip category redirects or disambigs."""
+        """Skip category redirects."""
         if page.isCategoryRedirect():
             pywikibot.warning(
                 'Page {page} on {page.site} is a category redirect. '
                 'Skipping.'.format(page=page))
             return True
-        if page.isDisambig():
-            pywikibot.warning(
-                'Page {page} on {page.site} is a disambiguation. '
-                'Skipping.'.format(page=page))
-            return True
         return super().skip_page(page)

     @staticmethod
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 34ffb9e..fa0a37e 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -515,6 +515,7 @@

     """References section bot."""

+    use_disambigs = False
     use_redirects = False

     def __init__(self, **kwargs) -> None:
@@ -708,11 +709,6 @@

     def skip_page(self, page):
         """Check whether the page could be processed."""
-        if page.isDisambig():
-            pywikibot.output('Page {} is a disambig; skipping.'
-                             .format(page.title(as_link=True)))
-            return True
-
         if self.site.sitename == 'wikipedia:en' and page.isIpEdit():
             pywikibot.warning(
                 'Page {} is edited by IP. Possible vandalized'

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/783817
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: I244c4a1c40c7337e9a4f35d5708af79b838fa336
Gerrit-Change-Number: 783817
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: DannyS712 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to