jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1167523?usp=email )

Change subject: IMPR: process_unlimited: warn if a username is not configured 
for site
......................................................................

IMPR: process_unlimited: warn if a username is not configured for site

Bug: T135228
Change-Id: I8c39f42b6c63bd168af91f411d2ebd6f27228df7
---
M scripts/interwiki.py
1 file changed, 26 insertions(+), 15 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 06af442..f441e51 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -1512,21 +1512,32 @@
                         break

     def process_unlimited(self, new, updated) -> None:
-        """Post process unlimited."""
-        for (site, page) in new.items():
-            # if we have an account for this site
-            if site.family.name in config.usernames \
-               and site.code in config.usernames[site.family.name] \
-               and not site.has_data_repository:
-                # Try to do the changes
-                try:
-                    if self.replaceLinks(page, new):
-                        # Page was changed
-                        updated.append(site)
-                except SaveError:
-                    pass
-                except GiveUpOnPage:
-                    break
+        """"Post-process pages: replace links and track updated sites."""
+        for site, page in new.items():
+            if site.has_data_repository:
+                self.conf.note(
+                    f'{site} has a data repository, skipping {page}'
+                )
+                continue
+
+            # Check if a username is configured for this site
+            codes = config.usernames.get(site.family.name, [])
+            if site.code not in codes:
+                pywikibot.warning(
+                    f'username for {site} is not given in your user-config.py'
+                )
+                continue
+
+            # Try to do the changes
+            try:
+                changed = self.replaceLinks(page, new)
+            except SaveError:
+                continue
+            except GiveUpOnPage:
+                break
+
+            if changed:
+                updated.append(site)

     def _fetch_text(self, page: pywikibot.Page) -> str:
         """Validate page and load it's content for editing.

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

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I8c39f42b6c63bd168af91f411d2ebd6f27228df7
Gerrit-Change-Number: 1167523
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to