jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1205493?usp=email )
Change subject: Fix interwiki.py delete links to ignored langs, instead ignore
......................................................................
Fix interwiki.py delete links to ignored langs, instead ignore
Bug: T410104
Change-Id: Id21ca23913ea9e807a02052ada1142056e10040c
---
M scripts/interwiki.py
1 file changed, 20 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index c2757f6..4b4853e 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -247,10 +247,12 @@
.. tip:: It is recommended to use this option with the
``-movelog`` pagegenerator.
--neverlink: Used as ``-neverlink:xx`` where xx is a language code,
- disregard any links found to language xx. You can also
- specify a list of languages to disregard, separated by
- commas.
+-neverlink: Used as ``-neverlink:xx`` where xx is a site code,
+ preserve existing interwiki links to site code xx without
+ checking or following them. This prevents the bot from
+ removing or modifying links to the specified site code(s),
+ treating them as correct. You can also specify a list of
+ site codes, separated by commas.
-ignore: Used as -ignore:xx:aaa where xx is a language code, and
aaa is a page title to be ignored.
@@ -1227,6 +1229,13 @@
for link in iw:
linkedPage = pywikibot.Page(link)
+
+ if linkedPage.site.code in self.conf.neverlink:
+ pywikibot.info(f'NOTE: {self.origin}: {page} has interwiki '
+ f'link to {linkedPage} in neverlink site code,'
+ ' preserving without following')
+ continue
+
if self.conf.hintsareright and linkedPage.site in self.hintedsites:
pywikibot.info(f'NOTE: {self.origin}: {page} extra interwiki '
f'on hinted site ignored {linkedPage}')
@@ -1637,6 +1646,13 @@
# Put interwiki links into a map
old = {p.site: p for p in interwikis}
+ # Preserve existing interwiki links to neverlink site codes
+ for site, oldpage in old.items():
+ if site.code in self.conf.neverlink and site not in new:
+ new[site] = oldpage
+ pywikibot.info(f'Preserving link to {oldpage} '
+ f'(site code {site.code} is in neverlink list)')
+
# Check what needs to get done
mods, mcomment, adding, removing, modifying = compareLanguages(
old, new, page.site, self.conf.summary)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1205493?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: Id21ca23913ea9e807a02052ada1142056e10040c
Gerrit-Change-Number: 1205493
Gerrit-PatchSet: 6
Gerrit-Owner: Dumbledore <[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]