Created
December 3, 2016 19:04
-
-
Save k-nut/eaa6f6ae2d4f06527ff81fab064e9974 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 set_active(politican_item_id): | |
| item = pywikibot.ItemPage(repo, politican_item_id) | |
| claims = item.get()['claims']['P39'] | |
| # Q17781726 is: Mitglied des Lantags Nordrhein-Westfahlen | |
| landtag_membership = next(claim for claim in claims if claim.target.id == 'Q17781726') | |
| qualifier = pywikibot.Claim(repo, u'P582') | |
| qualifier.setSnakType('novalue') # No end date, this is still their current position | |
| landtag_membership.addQualifier(qualifier) | |
| item.editEntity(summary='pyWikibot test edit') | |
| set_active(u"Q1157242") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment