jenkins-bot has submitted this change and it was merged.
Change subject: Prevent Page.change_category from readding newCat.
......................................................................
Prevent Page.change_category from readding newCat.
Currently change_category also adds newCat if it
is already present at the target page. This
behavior had to be fixed manually by calling
functions like category.py and causes extra code
and complexity.
Change-Id: I95ba291e78c2f187f4d4a881b39fa44096cca9b6
---
M pywikibot/page.py
1 file changed, 4 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index f0150cd..2cda41e 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1479,6 +1479,10 @@
% (self.title(asLink=True), oldCat.title()))
return
+ # This prevents the bot from adding newCat if it is already present.
+ if newCat in cats:
+ newCat = None
+
if inPlace or self.namespace() == 10:
oldtext = self.get(get_redirect=True)
newtext = pywikibot.replaceCategoryInPlace(oldtext, oldCat, newCat)
--
To view, visit
https://gerrit.wikimedia.org/r/104812
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I95ba291e78c2f187f4d4a881b39fa44096cca9b6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Pyfisch <pyfisch(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot