jenkins-bot has submitted this change and it was merged.
Change subject: use **kwargs in ItemPage.addClaim to support edit summary ......................................................................
use **kwargs in ItemPage.addClaim to support edit summary
The Wikibase extension (used on Wikidata) has recently enabled the edit summary on entities. ItemPage.editEntity and Claim.addSource already support it, but ItemPage.addClaim doesn't.
Change-Id: Id70a0be601f603238c8eed817cc5fc58c4705c88 --- M pywikibot/page.py M pywikibot/site.py 2 files changed, 6 insertions(+), 4 deletions(-)
Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index 7956ae1..8816da2 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -2615,7 +2615,7 @@ data = {'sitelinks': data} self.editEntity(data, **kwargs)
- def addClaim(self, claim, bot=True): + def addClaim(self, claim, bot=True, **kwargs): """ Adds the claim to the item @param claim The claim to add @@ -2623,7 +2623,7 @@ @param bot Whether to flag as bot (if possible) @type bot bool """ - self.repo.addClaim(self, claim, bot=bot) + self.repo.addClaim(self, claim, bot=bot, **kwargs) claim.on_item = self
def removeClaims(self, claims, **kwargs): diff --git a/pywikibot/site.py b/pywikibot/site.py index ef00047..7f2563b 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -3439,7 +3439,7 @@ return data
@must_be(group='user') - def addClaim(self, item, claim, bot=True): + def addClaim(self, item, claim, bot=True, **kwargs):
params = dict(action='wbcreateclaim', entity=item.getID(), @@ -3451,6 +3451,8 @@ params['bot'] = 1 if claim.getSnakType() == 'value': params['value'] = json.dumps(claim._formatDataValue()) + if 'summary' in kwargs: + params['summary'] = kwargs['summary'] params['token'] = self.token(item, 'edit') req = api.Request(site=self, **params) data = req.submit() @@ -3545,7 +3547,7 @@ params['claim'] = '|'.join(claim.snak for claim in claims) params['token'] = self.token(pywikibot.Page(self, u'Main Page'), 'edit') # Use a dummy page for kwarg in kwargs: - if kwarg in ['bot', 'baserevid']: + if kwarg in ['bot', 'baserevid', 'summary']: params[kwarg] = kwargs[kwarg] req = api.Request(site=self, **params) data = req.submit()
pywikibot-commits@lists.wikimedia.org