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)


--
To view, visit https://gerrit.wikimedia.org/r/533884
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3d219520244574b5ceafc40a50b8f2f0f73c946c
Gerrit-Change-Number: 533884
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Huji <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot (75)
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to