CommonsMedia#

class wikibaseintegrator.datatypes.commonsmedia.CommonsMedia(value=None, **kwargs)[source]#

Bases: URL

Implements the Wikibase data type for Wikimedia commons media files

Constructor, calls the superclass BaseDataType

Parameters:

value (str | None, default: None) – The URL to be used as the value

from_sparql_value(sparql_value)[source]#

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

The RDF representation is the full Wikimedia Commons URL of the file (e.g. http://commons.wikimedia.org/wiki/Special:FilePath/Example%20file.jpg), only the file name is kept. Without this, the URL implementation inherited by this class would store the whole URL, which would never match the file name held by a local claim.

Parameters:

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

Return type:

Self

Returns:

get_sparql_value(**kwargs)[source]#

The IRI of the file in the RDF export: its Special:FilePath URL on Wikimedia Commons, with the file name encoded like PHP’s rawurlencode() (a space is %20), e.g. <http://commons.wikimedia.org/wiki/Special:FilePath/Example%20file.jpg>

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 = 'commonsMedia'#
PTYPE = 'http://wikiba.se/ontology#CommonsMedia'#
SPARQL_IRI_PREFIX = 'http://commons.wikimedia.org/wiki/Special:FilePath/'#