Last active
December 3, 2016 21:20
-
-
Save k-nut/81fbbfb167ec6003b534379ccdaf33bb to your computer and use it in GitHub Desktop.
Add a Politician to the 16th Landtag in NRW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import pywikibot | |
import json | |
site = pywikibot.Site("wikidata", "wikidata") | |
repo = site.data_repository() | |
def mark_as_part_of_current_landtag(politican_item_id): | |
item = pywikibot.ItemPage(repo, politican_item_id) | |
claims = item.get()['claims']['P39'] | |
legislaturperiode = u'P2937' | |
landtag_period = u"Q27949540" # 16th NRW | |
# Q17781726 is: Mitglied des Lantags Nordrhein-Westfahlen | |
landtag_membership = next(claim for claim in claims if claim.target.id == 'Q17781726') | |
qualifier = pywikibot.Claim(repo, legislaturperiode) | |
target = pywikibot.ItemPage(repo, landtag_period) | |
qualifier.setTarget(target) | |
landtag_membership.addQualifier(qualifier) | |
item.editEntity(summary='pyWikibot politican in Wahlperiode') | |
mark_as_part_of_current_landtag(u"Q1322650") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment