ItemEntity#
- class wikibaseintegrator.entities.item.ItemEntity(labels=None, descriptions=None, aliases=None, sitelinks=None, **kwargs)[source]#
Bases:
TermsEntity- Parameters:
- add_claims(claims, action_if_exists=ActionIfExists.APPEND_OR_REPLACE)#
- Parameters:
claims (
Claim|list[Claim] |Claims) – A Claim, list of Claim or just a Claims object to add to the claims of this entity.action_if_exists (
ActionIfExists, default:ActionIfExists.APPEND_OR_REPLACE) – What to do when the property already has claims. Two claims are equal when they have the same property, value and qualifiers (the rank and the references are not compared). Defaults to APPEND_OR_REPLACE. APPEND_OR_REPLACE: Add the new claim if no equal claim exists. Otherwise, update the equal claim in place (same statement) instead of adding a duplicate: it takes the rank of the new claim if set (not normal), and its references if it has some (they replace the existing references). The other claims of the property are kept. MERGE_REFS_OR_APPEND: Add the new claim if no equal claim exists. Otherwise, add the references of the new claim missing from the equal claim. The other claims of the property are kept. FORCE_APPEND: Always add the new claim, even if an equal claim exists (duplicate statement). KEEP: Add the new claim only if the property has no claim yet, otherwise do nothing. REPLACE_ALL: Remove the claims of the property that are not equal to one of the new claims, then add the new claims not already present. The equal claims are kept as they are.
- Return type:
- Returns:
Return the updated entity object.
- clear(**kwargs)#
Use the clear parameter of wbeditentity API call to clear the content of the entity. The entity will be updated with an empty dictionary.
- delete(login=None, allow_anonymous=False, is_bot=None, **kwargs)#
Delete the current entity. Use the pageid first if available and fallback to the page title.
- Parameters:
login (
_Login|None, default:None) – A wbi_login.Login instanceallow_anonymous (
bool, default:False) – Allow an unidentified edit to the MediaWiki API (default False)is_bot (
bool|None, default:None) – Flag the edit as a botreason – Reason for the deletion. If not set, an automatically generated reason will be used.
deletetalk – Delete the talk page, if it exists.
kwargs (
Any) – Any additional keyword arguments to pass to mediawiki_api_call_helper and requests.request
- Return type:
- Returns:
The data returned by the API as a dictionary
- get(entity_id=None, **kwargs)[source]#
Request the MediaWiki API to get data for the entity specified in argument.
- Parameters:
- Return type:
- Returns:
an ItemEntity instance
- get_claims(property, login=None, allow_anonymous=True, is_bot=None, **kwargs)#
Load the claims of a property from the Wikibase instance. They replace the claims of this property already loaded, unsaved changes included, so calling it again refreshes them instead of duplicating them.
- Parameters:
- Return type:
- Returns:
This entity
- write(**kwargs)[source]#
Write the ItemEntity data to the Wikibase instance and return the ItemEntity object returned by the instance. This function extend
_write()- Parameters:
data – The serialized object that is used as the data source. A newly created entity will be assigned an ‘id’.
summary – A summary of the edit
login – A login instance
allow_anonymous – Force a check if the query can be anonymous or not
clear – Clear the existing entity before updating
is_bot – Add the bot flag to the query
kwargs (
Any) – More arguments for Python requests
- Return type:
- Returns:
an ItemEntity of the response from the instance
- write_required(base_filter, action_if_exists=ActionIfExists.REPLACE_ALL, **kwargs)#
- Return type:
- ETYPE = 'item'#
- property api: WikibaseIntegrator#
- property descriptions: Descriptions#