[feature-requests:#349] claimit.py: enable claim with the same property, but different value

Status: open
Labels: claimit.py wikidata enhancement python pywikibot
Created: Sun Sep 15, 2013 04:15 PM UTC by APAC
Last Updated: Sun Sep 15, 2013 04:15 PM UTC
Owner: nobody

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)

Sent from sourceforge.net because Pywikipedia-bugs@lists.wikimedia.org is subscribed to https://sourceforge.net/p/pywikipediabot/feature-requests/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/pywikipediabot/admin/feature-requests/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.