PropertyEntity#

class wikibaseintegrator.entities.property.PropertyEntity(datatype=None, labels=None, descriptions=None, aliases=None, **kwargs)[source]#

Bases: TermsEntity

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:

Self

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.

Parameters:

kwargs (Any) – More arguments for _write() and Python requests

Return type:

dict[str, Any]

Returns:

A dictionary representation of the edited Entity

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 instance

  • allow_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 bot

  • reason – 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:

dict

Returns:

The data returned by the API as a dictionary

download_entity_ttl(**kwargs)#
Return type:

str

from_json(json_data)[source]#

Import a dictionary into BaseEntity attributes.

Parameters:

json_data (dict[str, Any]) – A specific dictionary from MediaWiki API

Return type:

Self

Returns:

get(entity_id=None, **kwargs)[source]#

Request the MediaWiki API to get data for the entity specified in argument.

Parameters:
  • entity_id (str | int | None, default: None) – The ID of the entity to load, starting with ‘P’. By default, the ID of this entity, to reload it.

  • kwargs (Any)

Return type:

PropertyEntity

Returns:

a PropertyEntity 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:
  • property (str) – The property number, e.g. ‘P31’

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

  • allow_anonymous (bool, default: True) – Allow an anonymous request

  • is_bot (bool | None, default: None) – Add the bot flag to the query

  • kwargs (Any) – More arguments for Python requests

Return type:

Self

Returns:

This entity

get_entity_url(wikibase_url=None)#
Return type:

str

get_json()[source]#

To get the dict equivalent of the JSON representation of the entity.

Return type:

dict[str, str | Any]

Returns:

new(**kwargs)[source]#
Return type:

PropertyEntity

write(**kwargs)[source]#

Write the PropertyEntity data to the Wikibase instance and return the PropertyEntity object returned by the instance.

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:

PropertyEntity

Returns:

an PropertyEntity of the response from the instance

write_required(base_filter, action_if_exists=ActionIfExists.REPLACE_ALL, **kwargs)#
Return type:

bool

ETYPE = 'property'#
property aliases: Aliases#
property api: WikibaseIntegrator#
property claims: Claims#
Setter accepts:

Claim | Claims

property datatype: str | WikibaseDatatype | None#
property descriptions: Descriptions#
property id: str | None#
Setter accepts:

None | str | int

property labels: Labels#
property lastrevid: int | None#
property pageid: str | int | None#
property title: str | None#
property type: str#