Pamputt created this task.
Pamputt added a project: Pywikibot-core.
Herald added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION

Hello, first of all sorry if it is not a bug of if this feature already exists. I am learning python and pywikibot so it could be my mistake. What I want to do is presented here.
In summary, this piece of code illustrates my point (I hope)

p_stated_in = 'P248'
article_qid = ['Q45846010', 'Q45851113']
source_map = {p_stated_in: ['item',   article_qid]}
create_source_claim(new_claim, source_map)

def create_source_claim(claim, source_map):
    source_claims = []
    for src_prop in source_map.keys():
        target_type, source_value = source_map[src_prop]
        print('target: {0} , source: {1}, prop: {2}').format(target_type, source_value,src_prop)
        source_claim = pywikibot.Claim(repo, src_prop, isReference=True)
        if target_type == 'item':
            for qid in source_value:
                source_page = pywikibot.ItemPage(repo, qid)
                source_claim.setTarget(source_page)
                source_claims.append(source_claim)
        else:
            source_claim.setTarget(source_value)
        source_claims.append(source_claim)
    claim.addSources(source_claims, bot=True)
    return True

But doing that P248 has only the "Q45851113" value; "Q45846010" is not taken into account. Could you tell me how to do that?
And once more excuse me if this is not the right place but I tried to get some help from Wikidata previously but nothing.


TASK DETAIL
https://phabricator.wikimedia.org/T183492

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Pamputt
Cc: Aklapper, Pamputt, pywikibot-bugs-list, Magul, Tbscho, MayS, Mdupont, JJMC89, Avicennasis, jayvdb, Dalba, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to