set_claim#

wikibaseintegrator.wbi_helpers.set_claim(claim, entity_id=None, index=None, baserevid=None, summary=None, tags=None, ignore_duplicate_mainsnak=False, login=None, is_bot=False, **kwargs)[source]#

Create or replace a single statement, with its qualifiers and references, with the wbsetclaim API.

Unlike a write of the whole entity, only this statement is sent: the entity doesn’t need to be loaded first, and the edit doesn’t conflict with the edits of the other statements. A claim with an ID replaces the statement with this ID. A claim without an ID is added to the entity given by entity_id, and the ID generated for it is set on the claim once the edit is saved.

Parameters:
  • claim (Claim) – The claim to write, e.g. a datatype instance like String(prop_nr=’P31’, value=’foo’). It can’t be marked as removed, use remove_claims() instead.

  • entity_id (str | None, default: None) – The ID of the entity of a new claim (without ID). Optional for a claim with an ID, which already contains the ID of its entity.

  • index (int | None, default: None) – The position to move the statement to in the list of statements of the entity.

  • baserevid (int | None, default: None) – The numeric identifier for the revision to base the modification on. This is used for detecting conflicts during save.

  • summary (str | None, default: None) – Summary for the edit. Will be prepended by an automatically generated comment.

  • tags (list[str] | None, default: None) – Change tags to apply to the revision.

  • ignore_duplicate_mainsnak (bool, default: False) – Don’t save the statement if the entity already has a statement with the same main snak. The API then answers with a warning instead of the saved statement.

  • login (_Login | None, default: None) – A wbi_login.Login instance

  • is_bot (bool, default: False) – Mark this edit as bot.

  • kwargs (Any) – More arguments for mediawiki_api_call_helper() and Python requests

Return type:

dict

Returns:

The API response, with the saved statement in the ‘claim’ key.

Raises:
  • ValueError – if the claim is marked as removed, if a new claim has no entity_id, or if the ID of the claim doesn’t match entity_id

  • EmptyValueError – if a snak of the claim has no value