jenkins-bot has submitted this change and it was merged.
Change subject: Add support for setting statement ranks ......................................................................
Add support for setting statement ranks
Change-Id: I7111646de59ea5dea4ff686e53f8ac06cc7d9d75 --- M pywikibot/data/api.py M pywikibot/page.py M pywikibot/site.py 3 files changed, 35 insertions(+), 7 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index c6cbf67..db6117b 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1136,7 +1136,7 @@ "wbeditentity", "wbsetlabel", "wbsetdescription", "wbsetaliases", "wblinktitles", "wbsetsitelink", "wbcreateclaim", "wbremoveclaims", "wbsetclaimvalue", - "wbsetreference", "wbremovereferences" + "wbsetreference", "wbremovereferences", "wbsetclaim", ) # Client side verification that the request is being performed # by a logged in user, and warn if it isn't a config username. diff --git a/pywikibot/page.py b/pywikibot/page.py index 3f9c93a..851f342 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -4150,13 +4150,14 @@ """Return the rank of the Claim.""" return self.rank
- def setRank(self): - """ - Set the rank of the Claim. + def setRank(self, rank): + """Set the rank of the Claim.""" + self.rank = rank
- Has not been implemented in the Wikibase API yet - """ - raise NotImplementedError + def changeRank(self, rank): + """Change the rank of the Claim and save.""" + self.rank = rank + return self.repo.save_claim(self)
def changeSnakType(self, value=None, **kwargs): """ diff --git a/pywikibot/site.py b/pywikibot/site.py index eae3500..0140163 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -5776,6 +5776,33 @@ return data
@must_be(group='user') + def save_claim(self, claim, **kwargs): + """ + Save the whole claim to the wikibase site. + + @param claim: The claim to save + @type claim: Claim + """ + if claim.isReference or claim.isQualifier: + raise NotImplementedError + if not claim.snak: + # We need to already have the snak value + raise NoPage(claim) + params = {'action': 'wbsetclaim', + 'claim': json.dumps(claim.toJSON()), + 'token': self.tokens['edit'], + 'baserevid': claim.on_item.lastrevid, + } + if 'bot' not in kwargs or kwargs['bot']: + params['bot'] = True + if 'summary' in kwargs: + params['summary'] = kwargs['summary'] + + req = api.Request(site=self, **params) + data = req.submit() + return data + + @must_be(group='user') def editSource(self, claim, source, new=False, bot=True, **kwargs): """ Create/Edit a source.
pywikibot-commits@lists.wikimedia.org