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
---
** [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 [email protected] 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._______________________________________________
Pywikipedia-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-bugs