BaseDataType#

class wikibaseintegrator.datatypes.basedatatype.BaseDataType(prop_nr=None, **kwargs)[source]#

Bases: Claim

The base class for all Wikibase data types, they inherit from it

Constructor, will be called by all data types.

Parameters:

prop_nr (int | str | None, default: None) – The property number a Wikibase snak belongs to

classmethod get_datatype_class(datatype)[source]#

Find the data type class handling a datatype, as named by the Wikibase API.

Parameters:

datatype (str) – The datatype, e.g. ‘wikibase-item’ or WikibaseDatatype.ITEM

Return type:

type[BaseDataType]

Returns:

The data type class, e.g. Item

Raises:

UnknownDatatypeError – If no data type class handles this datatype

from_sparql_value(sparql_value)[source]#

Parse data returned by a SPARQL endpoint and set the value to the object

This generic implementation covers the data types whose RDF representation is the literal value itself (external identifiers, musical notation…). The data types backed by a URI (entities, media files) override it to extract the value from that URI, since storing the raw URI would silently never match a local claim.

Parameters:

sparql_value (dict) – A SPARQL value composed of type and value

Return type:

Self

Returns:

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

str | None

parse_sparql_value(value, type='literal', unit='1')[source]#
Return type:

bool

set_value(value=None)[source]#
Return type:

None

DTYPE = 'base-data-type'#
PTYPE = 'property-data-type'#