jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/258684 )
Change subject: Add async parameter to ItemPage.editEntity
......................................................................
Add async parameter to ItemPage.editEntity
'asynchronous' parameter enables ItemPage.editEntity to edit an entity
asynchronously, which can be used in Wikidata bots.
TODO:
- needs better exception handling? (T86083)
- new callback argument, just like in BasePage.save()
Bug: T86074
Change-Id: I1ffa92b8710e91b7095b24808c151ff9d0a592cf
---
M pywikibot/bot.py
M pywikibot/page.py
2 files changed, 8 insertions(+), 2 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 80905bf..9a24644 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1866,7 +1866,6 @@
if 'summary' in kwargs:
pywikibot.output(u'Change summary: %s' % kwargs['summary'])
- # TODO async in editEntity should actually have some effect (bug T86074)
# TODO PageSaveRelatedErrors should be actually raised in editEntity
# (bug T86083)
self._save_page(item, item.editEntity, data, **kwargs)
diff --git a/pywikibot/page.py b/pywikibot/page.py
index dc34774..a1540f4 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -3541,7 +3541,7 @@
return site.dbName()
return site
- def editEntity(self, data=None, **kwargs):
+ def editEntity(self, data=None, asynchronous=False, **kwargs):
"""
Edit an entity using Wikibase wbeditentity API.
@@ -3553,7 +3553,14 @@
@param data: Data to be saved
@type data: dict, or None to save the current content of the entity.
+ @param asynchronous: if True, launch a separate thread to edit
+ asynchronously
+ @type asynchronous: bool
"""
+ if asynchronous:
+ pywikibot.async_request(self.editEntity, data, **kwargs)
+ return
+
if hasattr(self, '_revid'):
baserevid = self.latest_revision_id
else:
--
To view, visit
https://gerrit.wikimedia.org/r/258684
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1ffa92b8710e91b7095b24808c151ff9d0a592cf
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Vadiraja.k <vadi.fedx(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: M4tx <m4tx(a)m4tx.pl>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: MarcoAurelio <strigiwm(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>