wikibaseintegrator.entities.item

class wikibaseintegrator.entities.item.ItemEntity(labels=None, descriptions=None, aliases=None, sitelinks=None, **kwargs)[source]

Bases: BaseEntity

Parameters:
ETYPE = 'item'
__init__(labels=None, descriptions=None, aliases=None, sitelinks=None, **kwargs)[source]
Parameters:
Return type:

None

add_claims(claims, action_if_exists=ActionIfExists.APPEND_OR_REPLACE)
Parameters:
  • claims (Union[Claim, List[Claim], Claims]) – A Claim, list of Claim or just a Claims object to add to this Claims object.

  • action_if_exists (ActionIfExists) – Replace or append the statement. You can force an addition if the declaration already exists. KEEP: The original claim will be kept and the new one will not be added (because there is already one with this property number) APPEND_OR_REPLACE: The new claim will be added only if the new one is different (by comparing values) FORCE_APPEND: The new claim will be added even if already exists REPLACE_ALL: The new claim will replace the old one

Return type:

BaseEntity

Returns:

Return the updated entity object.

property aliases: Aliases
property api: WikibaseIntegrator
property claims: Claims
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 (Optional[_Login]) – A wbi_login.Login instance

  • allow_anonymous (bool) – Allow an unidentified edit to the MediaWiki API (default False)

  • is_bot (Optional[bool]) – 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

Returns:

The data returned by the API as a dictionary

property descriptions: Descriptions
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:

ItemEntity

Returns:

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

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

Parameters:
  • entity_id (Union[str, int, None]) – The entity_id of the Item entity you want. Must start with a ‘Q’.

  • kwargs (Any) –

Return type:

ItemEntity

Returns:

an ItemEntity instance

get_entity_url(wikibase_url=None)
Return type:

str

Parameters:

wikibase_url (str | None) –

get_json()[source]

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

Return type:

Dict[str, Union[str, Dict]]

Returns:

A dict representation of the Item.

property id: str | None
property labels: Labels
property lastrevid: int | None
new(**kwargs)[source]
Return type:

ItemEntity

Parameters:

kwargs (Any) –

property pageid: str | int | None
property title: str | None
property type: str
write(**kwargs)[source]

Write the ItemEntity data to the Wikibase instance and return the ItemEntity object returned by the instance. 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:

ItemEntity

Returns:

an ItemEntity of the response from the instance

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

bool

Parameters: