wikibaseintegrator.wbi_fastrun

class wikibaseintegrator.wbi_fastrun.FastRunContainer(base_data_type, mediawiki_api_url=None, sparql_endpoint_url=None, wikibase_url=None, base_filter=None, use_refs=False, case_insensitive=False)[source]

Bases: object

Parameters:
  • base_data_type (type[BaseDataType])

  • mediawiki_api_url (str | None)

  • sparql_endpoint_url (str | None)

  • wikibase_url (str | None)

  • base_filter (list[BaseDataType | list[BaseDataType]] | None)

  • use_refs (bool)

  • case_insensitive (bool)

__init__(base_data_type, mediawiki_api_url=None, sparql_endpoint_url=None, wikibase_url=None, base_filter=None, use_refs=False, case_insensitive=False)[source]
Parameters:
  • base_data_type (type[BaseDataType])

  • mediawiki_api_url (str | None)

  • sparql_endpoint_url (str | None)

  • wikibase_url (str | None)

  • base_filter (list[BaseDataType | list[BaseDataType]] | None)

  • use_refs (bool)

  • case_insensitive (bool)

check_language_data(qid, lang_data, lang, lang_data_type, action_if_exists=ActionIfExists.APPEND_OR_REPLACE)[source]

Method to check if certain language data exists as a label, description or aliases :type qid: str :param qid: Wikibase item id :type lang_data: list :param lang_data: list of string values to check :type lang: str :param lang: language code :type lang_data_type: str :param lang_data_type: What kind of data is it? ‘label’, ‘description’ or ‘aliases’? :type action_if_exists: ActionIfExists :param action_if_exists: If aliases already exist, APPEND_OR_REPLACE or REPLACE_ALL :rtype: bool :return: boolean

Parameters:
  • qid (str)

  • lang_data (list)

  • lang (str)

  • lang_data_type (str)

  • action_if_exists (ActionIfExists)

Return type:

bool

clear()[source]

convenience function to empty this fastrun container

Return type:

None

format_query_results(r, prop_nr)[source]

r is the results of the sparql query in _query_data and is modified in place prop_nr is needed to get the property datatype to determine how to format the value

Return type:

None

Parameters:
  • r (list)

  • prop_nr (str)

r is a list of dicts. The keys are:

sid: statement ID item: the subject. the item this statement is on v: the object. The value for this statement unit: property unit pq: qualifier property qval: qualifier value qunit: qualifier unit ref: reference ID pr: reference property rval: reference value

get_all_data()[source]
Return type:

dict[str, dict]

get_item(claims, cqid=None)[source]
Parameters:
  • claims (list[Claim] | Claims | Claim) – A list of claims the entity should have

  • cqid (str | None)

Return type:

str | None

Returns:

An entity ID, None if there is more than one.

get_items(claims, cqid=None)[source]

Get items ID from a SPARQL endpoint

Parameters:
  • claims (list[Claim] | Claims | Claim) – A list of claims the entities should have

  • cqid (str | None)

Return type:

set[str] | None

Returns:

a list of entity ID or None

Exception:

if there is more than one claim

get_language_data(qid, lang, lang_data_type)[source]

get language data for specified qid

Parameters:
  • qid (str) – Wikibase item id

  • lang (str) – language code

  • lang_data_type (str) – ‘label’, ‘description’ or ‘aliases’

Return type:

list[str]

Returns:

list of strings

If nothing is found:

If lang_data_type == label: returns [‘’] If lang_data_type == description: returns [‘’] If lang_data_type == aliases: returns []

get_prop_datatype(prop_nr)[source]
Return type:

str | None

Parameters:

prop_nr (str)

init_language_data(lang, lang_data_type)[source]

Initialize language data store

Parameters:
  • lang (str) – language code

  • lang_data_type (str) – ‘label’, ‘description’ or ‘aliases’

Return type:

None

Returns:

None

reconstruct_statements(qid)[source]
Return type:

list[BaseDataType]

Parameters:

qid (str)

update_frc_from_query(r, prop_nr)[source]
Return type:

None

Parameters:
  • r (list)

  • prop_nr (str)

write_required(data, action_if_exists=ActionIfExists.REPLACE_ALL, cqid=None)[source]

Check if a write is required

Parameters:
Return type:

bool

Returns:

Return True if the write is required

wikibaseintegrator.wbi_fastrun.get_fastrun_container(base_filter=None, use_refs=False, case_insensitive=False)[source]
Return type:

FastRunContainer

Parameters: