Last modified: 2014-02-01 17:07:18 UTC
Originally from: http://sourceforge.net/p/pywikipediabot/feature-requests/349/ Reported by: apac1 Created on: 2013-09-15 16:15:03.602000 Subject: claimit.py: enable claim with the same property, but different value Original labels: claimit.py, wikidata, enhancement, python, pywikibotOriginal description: The below can be added to claimit.py to enable adding statements on items with the same property, but different values. https://github.com/wikimedia/pywikibot-core/blob/master/scripts/claimit.py :::python for claim in self.claims: if claim.getID() in item.get().get('claims'): propertytoadd = claim.getID() for valueofproperty in item.claims[propertytoadd]: if valueofproperty.getTarget() == claim.getTarget(): pywikibot.output("item for %s has already property %s with value %s" % (page.title(), propertytoadd, valueofproperty.getTarget())) break else: continue else: pywikibot.output('Adding additional %s --> %s' % (claim.getID(), claim.getTarget())) item.addClaim(claim) else: pywikibot.output('Adding %s --> %s' % (claim.getID(), claim.getTarget())) item.addClaim(claim)
slightly improved version, merged with the new "source" function :::python for claim in self.claims: if claim.getID() in item.get().get('claims'): for existingclaimwithproperty in item.claims[claim]: if existingclaimwithproperty.getTarget() == claim.getTarget(): pywikibot.output("item for %s has already property %s with value %s" % (page.title(), claim, existingclaimwithproperty.getTarget())) break else: continue else: pywikibot.output('Adding additional %s --> %s' % (claim.getID(), claim.getTarget())) item.addClaim(claim) source = self.getSource(page.site.language()) if self.source: claim.addSource(self.source, bot=True) # TODO FIXME: We need to check that we aren't adding a # duplicate source else: pywikibot.output('Adding %s --> %s' % (claim.getID(), claim.getTarget())) item.addClaim(claim) source = self.getSource(page.site.language()) if self.source: claim.addSource(self.source, bot=True) # TODO FIXME: We need to check that we aren't adding a # duplicate source
Change 92073 had a related patch set uploaded by Merlijn van Deen: Enable adding statements on items with the same property, but different values. https://gerrit.wikimedia.org/r/92073
Change 97198 had a related patch set uploaded by Tholam: Enable claims with the same property, but different value for claimit.py https://gerrit.wikimedia.org/r/97198
Change 92073 abandoned by Merlijn van Deen: Enable adding statements on items with the same property, but different values. Reason: One of the GCI students has worked on this: https://gerrit.wikimedia.org/r/#/c/97198/ https://gerrit.wikimedia.org/r/92073
Change 97198 merged by jenkins-bot: Enable claims with the same property, but different value for claimit.py https://gerrit.wikimedia.org/r/97198
*** Bug 54542 has been marked as a duplicate of this bug. ***