wikibaseintegrator.entities.baseentity

class wikibaseintegrator.entities.baseentity.BaseEntity(api=None, title=None, pageid=None, lastrevid=None, type=None, id=None, claims=None, is_bot=None, login=None)[source]

Bases: object

Parameters:
  • api (Optional['WikibaseIntegrator']) –

  • title (Optional[str]) –

  • pageid (Optional[int]) –

  • lastrevid (Optional[int]) –

  • type (Optional[str]) –

  • id (Optional[str]) –

  • claims (Optional[Claims]) –

  • is_bot (Optional[bool]) –

  • login (Optional[_Login]) –

ETYPE = 'base-entity'
__init__(api=None, title=None, pageid=None, lastrevid=None, type=None, id=None, claims=None, is_bot=None, login=None)[source]
Parameters:
  • api (WikibaseIntegrator | None) –

  • title (str | None) –

  • pageid (int | None) –

  • lastrevid (int | None) –

  • type (str | None) –

  • id (str | None) –

  • claims (Claims | None) –

  • is_bot (bool | None) –

  • login (_Login | None) –

add_claims(claims, action_if_exists=ActionIfExists.APPEND_OR_REPLACE)[source]
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 api: WikibaseIntegrator
property claims: Claims
clear(**kwargs)[source]

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)[source]

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

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:

BaseEntity

Returns:

get_entity_url(wikibase_url=None)[source]
Return type:

str

Parameters:

wikibase_url (str | None) –

get_json()[source]

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

Return type:

Dict[str, Union[str, Dict[str, List]]]

Returns:

property id: str | None
property lastrevid: int | None
property pageid: str | int | None
property title: str | None
property type: str
write_required(base_filter=None, action_if_exists=ActionIfExists.REPLACE_ALL, **kwargs)[source]
Return type:

bool

Parameters: