wikibaseintegrator.models.claims

class wikibaseintegrator.models.claims.Claim(qualifiers=None, rank=None, references=None, snaktype=WikibaseSnakType.KNOWN_VALUE)[source]

Bases: BaseModel

Parameters:
DTYPE = 'claim'
__init__(qualifiers=None, rank=None, references=None, snaktype=WikibaseSnakType.KNOWN_VALUE)[source]
Parameters:
Return type:

None

equals(that, include_ref=False, fref=None)[source]

Tests for equality of two statements. If comparing references, the order of the arguments matters!!! self is the current statement, the next argument is the new statement. Allows passing in a function to use to compare the references ‘fref’. Default is equality. fref accepts two arguments ‘oldrefs’ and ‘newrefs’, each of which are a list of references, where each reference is a list of statements

Return type:

bool

Parameters:
  • that (Claim)

  • include_ref (bool)

  • fref (Callable | None)

from_json(json_data)[source]
Parameters:

json_data (dict[str, Any]) – a JSON representation of a Claim

Return type:

Claim

get_json()[source]
Return type:

dict[str, Any]

abstract get_sparql_value()[source]
Return type:

str

has_equal_qualifiers(other)[source]
Return type:

bool

Parameters:

other (Claim)

property id: str | None
property mainsnak: Snak
property qualifiers: Qualifiers
property qualifiers_order: list[str]
static quals_equal(olditem, newitem)[source]

Tests for exactly identical qualifiers.

Return type:

bool

Parameters:
property rank: WikibaseRank
static ref_present(olditem, newitem)[source]

Tests if (1) there is a single ref in the new item and (2) if this single ref is present among the claims of the old item.

Return type:

bool

Parameters:
property references: References
static refs_equal(olditem, newitem)[source]

tests for exactly identical references

Return type:

bool

Parameters:
remove(remove=True)[source]
Return type:

None

property removed: bool
reset_id()[source]

Reset the ID of the current claim

property type: str | dict
update(claim)[source]
Return type:

None

Parameters:

claim (Claim)

class wikibaseintegrator.models.claims.Claims[source]

Bases: BaseModel

__init__()[source]
Return type:

None

add(claims, action_if_exists=ActionIfExists.REPLACE_ALL)[source]
Parameters:
  • claims (Claims | list[Claim] | Claim) – 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. Defaults to REPLACE_ALL. 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:

Claims

Returns:

Return the updated Claims object.

property claims: dict[str, list[Claim]]
from_json(json_data)[source]
Return type:

Claims

Parameters:

json_data (dict[str, Any])

get(property)[source]
Return type:

list[Claim]

Parameters:

property (str | int)

get_json()[source]
Return type:

dict[str, list]

remove(property=None)[source]
Return type:

None

Parameters:

property (str | None)