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 (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)
- 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 (
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:
- Returns:
Return the updated entity object.
- property api: WikibaseIntegrator
- 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 (
_Login
|None
) – A wbi_login.Login instanceallow_anonymous (
bool
) – Allow an unidentified edit to the MediaWiki API (default False)is_bot (
bool
|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
- 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:
- Returns:
- get_json()[source]
To get the dict equivalent of the JSON representation of the entity.
- Return type:
dict
[str
,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:
base_filter (list[BaseDataType | list[BaseDataType]] | None)
action_if_exists (ActionIfExists)
kwargs (Any)