jenkins-bot merged this change.
[bugfix] Skip the category to be created
Currently the source page will be skipped if it already exists
instead of the target category. This patch solves that bug.
Bug: T231791
Change-Id: I3d219520244574b5ceafc40a50b8f2f0f73c946c
---
M scripts/create_categories.py
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/scripts/create_categories.py b/scripts/create_categories.py
index d902de8..b42cb8e 100755
--- a/scripts/create_categories.py
+++ b/scripts/create_categories.py
@@ -59,8 +59,9 @@
self.basename = basename
self.overwrite = overwrite
- def treat(self, page):
- """Create category in commons for that page."""
+ def init_page(self, item):
+ """Create a category to be processed with the given page title."""
+ page = super(CreateCategoriesBot, self).init_page(item)
title = page.title(with_ns=False)
newpage = pywikibot.Category(pywikibot.Site('commons', 'commons'),
@@ -68,8 +69,13 @@
newtext = ('[[Category:%(parent)s|%(title)s]]\n'
'[[Category:%(title)s]]\n'
% {'parent': self.parent, 'title': title})
+ newpage.text = newtext
+ return newpage
- self.current_page = newpage
+ def treat(self, page):
+ """Create category in commons for that page."""
+ newtext = page.text
+ self.current_page = page
self.current_page.text = ''
self.put_current(newtext, ignore_server_errors=True)
To view, visit change 533884. To unsubscribe, or for help writing mail filters, visit settings.