Skip to content

Commit

Permalink
version 0.9.8 with both qid and local json data support on wdi_rdf
Browse files Browse the repository at this point in the history
  • Loading branch information
andrawaag committed Aug 26, 2021
1 parent f4015e2 commit bf7308a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion wikidataintegrator/wdi_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,6 @@ def get_sitelink(self, site):
else:
return None


def write(self, login, bot_account=True, edit_summary='', entity_type='item', property_datatype='string',
max_retries=1000, retry_after=60):
"""
Expand Down
16 changes: 12 additions & 4 deletions wikidataintegrator/wdi_rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@


class WDqidRDFEngine(object):
def __init__(self, qid, fetch_provenance_rdf=True, fetch_metadata_rdf=True, fetch_truthy_rdf=False,
def __init__(self, qid=None, json_data=None, fetch_provenance_rdf=True, fetch_metadata_rdf=True, fetch_truthy_rdf=False,
fetch_normalized_rdf=False, fetch_sitelinks_rdf=False,
fetch_merged_items_rdf=False, fetch_property_descriptions_rdf=False, fetch_labels_rdf=True,
fetch_linked_items_rdf=False, fetch_all=False):
if not bool(qid) and not bool(json_data):
raise ValueError('Please provide either a QID or a json object of a Wikidata item')

if bool(qid) and bool(data):
raise ValueError('Please provide only a QID or a JSON object of a Wikidata item, not both')

self.qid = qid
if fetch_all:
self.fetch_provenance_rdf = True
Expand All @@ -42,9 +48,11 @@ def __init__(self, qid, fetch_provenance_rdf=True, fetch_metadata_rdf=True, fetc
self.fetch_sitelinks_rdf = fetch_sitelinks_rdf
self.fetch_truthy_rdf = fetch_truthy_rdf
self.fetch_linked_items_rdf = fetch_linked_items_rdf

self.json_item = json.loads(requests.get("http://www.wikidata.org/entity/" + qid + ".json").text)["entities"][
qid]
if bool(qid):
self.json_item = json.loads(requests.get("http://www.wikidata.org/entity/" + qid + ".json").text)["entities"][
qid]
else:
self.json_item = json_data
self.rdf_item = Graph()
self.ns = dict()
self.linked_items = []
Expand Down

0 comments on commit bf7308a

Please sign in to comment.