# county council specific constituency if not cities[county].get('county_councilor_constituency'): county_constituency_label = '%s區議員選區' % county try: item_id = utils.get_qnumber(wikiarticle=county_constituency_label, lang="zh") if not item_id: raise county_constituency_item = pywikibot.ItemPage(repo, item_id) county_constituency_item.get() if county_constituency_item.labels[ 'zh'] != county_constituency_label: raise except: labels = {"zh": county_constituency_label} item_id = utils.create_item(wikidata_site, labels) county_constituency_item = pywikibot.ItemPage(repo, item_id) county_constituency_item.get() cities[county][ 'county_councilor_constituency'] = county_constituency_item.id else: county_constituency_item = pywikibot.ItemPage( repo, cities[county]['county_councilor_constituency']) county_constituency_item.get() if not county_constituency_item.labels.get('en'): labels = {'en': 'Council Constituency of %s' % cities[county]['en']} for code in ['zh', 'zh-tw', 'zh-hant']: labels[code] = county_constituency_label county_constituency_item.editLabels(labels, asynchronous=False)
lang="zh", limit=None): position_item = pywikibot.ItemPage(repo, q_id) position_item.get() if position_item.claims.get('P31') and 'Q4164871' in [ x.target.id for x in position_item.claims['P31'] ]: # Q4164871 職位 match = True break if not match: raise except: position_labels = {'en': '%s councilor' % v['en']} for code in ['zh', 'zh-tw', 'zh-hant']: position_labels[code] = position position_item_id = utils.create_item(wikidata_site, position_labels) position_item = pywikibot.ItemPage(repo, position_item_id) position_item.get() print('new position page created.') else: position_item = pywikibot.ItemPage(repo, v['councilor_position']) position_item.get() print(position_item, position_item.id) cities[county]['councilor_position'] = position_item.id # 性質 try: if 'Q4164871' not in [ x.target.id for x in position_item.claims['P31'] ]: raise