Multichill added a comment.

Simple python script to reproduce:

  def addItemStatement(repo, item, pid, qid, url, i):
      '''
      Helper function to add a statement
      '''
      if not qid:
          return False
  
      claims = item.get().get('claims')
      if pid in claims:
          return
      
      newclaim = pywikibot.Claim(repo, pid)
      destitem = pywikibot.ItemPage(repo, qid)
      if destitem.isRedirectPage():
          destitem = destitem.getRedirectTarget()
  
      newclaim.setTarget(destitem)
      pywikibot.output(u'Adding %s->%s to %s' % (pid, qid, item))
      item.addClaim(newclaim)
      pywikibot.output(u'The current revision id is %s after adding a claim' % 
(item.latest_revision_id,))
  
  def main():
      '''
      '''
      repo = pywikibot.Site(u'test', u'wikidata').data_repository()
  
      data = {'labels': { 'en' : {'language': u'en',
                                  'value': u'Tester de test for T104522'}
                          },
              }
                
      print data
                  
      identification = {}
      summary = u'Creating new itemu'
      pywikibot.output(summary)
      result = repo.editEntity(identification, data, summary=summary)
      itemTitle = result.get(u'entity').get('id')
  
      # Wikidata is sometimes lagging. Wait for 10 seconds before trying to 
actually use the item
      #time.sleep(10)
                  
      item = pywikibot.ItemPage(repo, title=itemTitle)
  
      pywikibot.output(u'The current revision id is %s' % 
(item.latest_revision_id,))
  
      pid = u'P508'
      qid = u'Q207'
      url = u'https://www.google.com/'
  
      for i in range(0,4):
          pywikibot.output(u'The current revision id is %s at the start of %s' 
% (item.latest_revision_id,i))
          addItemStatement(repo, item, pid, qid, url, i)   
      
  
  if __name__ == "__main__":
      main()

At 
https://phabricator.wikimedia.org/diffusion/PWBC/browse/master/pywikibot/site.py;a8539a78ff659e71c4fb011b6797f20e6c369edc$6981
 you want to dump params and data.


TASK DETAIL
  https://phabricator.wikimedia.org/T104522

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Multichill
Cc: Multichill, Ricordisamoa, Aklapper, jayvdb, pywikibot-bugs-list, 
Wikidata-bugs, aude, Mbch331



_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to