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:
pywikibot-commits@lists.wikimedia.org