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 (Optional[str]) –

  • sparql_endpoint_url (Optional[str]) –

  • wikibase_url (Optional[str]) –

  • base_filter (Optional[List[BaseDataType | List[BaseDataType]]]) –

  • 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 (Optional[str]) –

  • sparql_endpoint_url (Optional[str]) –

  • wikibase_url (Optional[str]) –

  • base_filter (Optional[List[BaseDataType | List[BaseDataType]]]) –

  • 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 (Union[List[Claim], Claims, Claim]) – A list of claims the entity should have

  • cqid (Optional[str]) –

Return type:

Optional[str]

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 (Union[List[Claim], Claims, Claim]) – A list of claims the entities should have

  • cqid (Optional[str]) –

Return type:

Optional[Set[str]]

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:

Optional[str]

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: