jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/533884 )
Change subject: [bugfix] Skip the category to be created ......................................................................
[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(-)
Approvals: Huji: Looks good to me, approved jenkins-bot: Verified
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)
pywikibot-commits@lists.wikimedia.org