jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/481664 )

Change subject: [IMPR] Make Wikidata bots add claims with sources in a single 
edit
......................................................................

[IMPR] Make Wikidata bots add claims with sources in a single edit

This has been possible since Id44613daa30ad7b8ba40134e4db496a0e4a927b0.

Change-Id: Iaadd5704268b62dbf57fff3263f46503beb86459
---
M pywikibot/bot.py
1 file changed, 4 insertions(+), 20 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 916ff41..eebfb10 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1986,22 +1986,6 @@
             ignore_save_related_errors=ignore_save_related_errors,
             ignore_server_errors=ignore_server_errors, **kwargs)

-    def _add_source_callback(self, claim, source, **kwargs):
-        """
-        Make a callback for user_add_claim.
-
-        @return: callback to be executed after saving the claim
-        @rtype: callable or None
-        """
-        callback = None
-        sourceclaim = self.getSource(source)
-        if sourceclaim:
-            def callback(item, err):
-                if err is None and claim.on_item is not None:
-                    claim.addSource(sourceclaim, **kwargs)
-
-        return callback
-
     def user_add_claim(self, item, claim, source=None, bot=True, **kwargs):
         """
         Add a claim to an item, with user confirmation as required.
@@ -2025,14 +2009,14 @@
         """
         self.current_page = item

-        callback = None
         if source:
-            callback = self._add_source_callback(claim, source, bot=bot)
+            sourceclaim = self.getSource(source)
+            if sourceclaim:
+                claim.addSource(sourceclaim)

         pywikibot.output('Adding %s --> %s' % (claim.getID(),
                                                claim.getTarget()))
-        return self._save_page(item, item.addClaim, claim, bot=bot,
-                               callback=callback, **kwargs)
+        return self._save_page(item, item.addClaim, claim, bot=bot, **kwargs)

     def getSource(self, site):
         """

--
To view, visit https://gerrit.wikimedia.org/r/481664
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: Iaadd5704268b62dbf57fff3263f46503beb86459
Gerrit-Change-Number: 481664
Gerrit-PatchSet: 1
Gerrit-Owner: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: John Vandenberg <[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