Example #1
0
    def parse_node(self, item: wdi_core.WDItemEngine):
        type_statements = [s for s in item.statements if s.get_prop_nr() == self.type_pid]
        if len(type_statements) != 1:
            return None
        node_template = dict()
        node_template[':LABEL'] = self.qid_dbxref["Q" + str(type_statements[0].get_value())]
        node_template['id:ID'] = self.qid_dbxref[item.wd_item_id]
        node_template['preflabel'] = self.undo_id_parenthesis(item.get_label())
        node_template['name'] = item.get_label()
        node_template['description'] = item.get_description()
        node_template['synonyms:IGNORE'] = "|".join(item.get_aliases())

        return node_template
Example #2
0
def _temp_route_oauth_write_test():
    # One-off test to ensure pipes are running, add an alias to WikiDP item
    identity = identify_user()
    for key in identity.keys():
        logging.info('KEY: %s VALUE: %s', key, identity.get(key))
    item = WDItemEngine(wd_item_id="Q51139559")
    item.set_aliases(['WikiDP Application'], append=True)
    # verify the api is working by getting this item
    assert item.get_label() == "Wikidata for Digital Preservation"
    wdi_login = get_wdi_login()
    # verify edit token exists, this is what WDI calls
    assert wdi_login.get_edit_token()
    assert "user" in identity.get('groups')  # verify user in user group
    # verify user in user group
    assert "autoconfirmed" in identity.get('groups')
    assert "edit" in identity.get('rights')  # verify user in user group
    assert "editpage" in identity.get('grants')  # verify user in user group
    updated = item.write(wdi_login)  # fails due to no permissions
    return jsonify(updated)
Example #3
0
def item():
    wd_item = WDItemEngine(
        wd_item_id="Q14911732",
        mediawiki_api_url='https://www.wikidataaaaaa.org/w/api.php',
        search_only=True)
    print(wd_item.get_label('en'))
Example #4
0
def item():
    wd_item = WDItemEngine(wd_item_id="Q14911732",
                           server='www.wikidataaaaaaaaa.org',
                           search_only=True)
    print(wd_item.get_label('en'))