jenkins-bot has submitted this change and it was merged.
Change subject: add API:wbmergeitems support to DataSite and ItemPage ......................................................................
add API:wbmergeitems support to DataSite and ItemPage
see https://www.mediawiki.org/wiki/Extension:Wikibase/API#wbmergeitems
Change-Id: I7e5a70eb5605265b5d00b087be88d1f296248446 --- M pywikibot/page.py M pywikibot/site.py 2 files changed, 30 insertions(+), 0 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index b75bbc3..5d26fbe 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -2739,6 +2739,14 @@ claims = [claims] self.repo.removeClaims(claims, **kwargs)
+ def mergeInto(self, item, **kwargs): + """ + Merges the item into another item + @param item: The item to merge into + @type item: pywikibot.ItemPage + """ + self.repo.mergeItems(fromItem=self, toItem=item, **kwargs) +
class PropertyPage(WikibasePage): """ diff --git a/pywikibot/site.py b/pywikibot/site.py index 3d85c6b..78196a5 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -3944,6 +3944,28 @@ data = req.submit() return data
+ def mergeItems(self, fromItem, toItem, **kwargs): + """ + Merge two items together + @param fromItem: Item to merge from + @type fromItem: pywikibot.ItemPage + @param toItem: Item to merge into + @type toItem: pywikibot.ItemPage + @return: dict API output + """ + params = { + 'action': 'wbmergeitems', + 'fromid': fromItem.getID(), + 'toid': toItem.getID(), + 'token': self.token(toItem, 'edit') + } + for kwarg in kwargs: + if kwarg in ['ignoreconflicts', 'summary']: + params[kwarg] = kwargs[kwarg] + req = api.Request(site=self, **params) + data = req.submit() + return data + # deprecated BaseSite methods def fam(self): raise NotImplementedError
pywikibot-commits@lists.wikimedia.org