Topic on Manual talk:Pywikibot

Soued031 (talkcontribs)

Hello,

I've written a script whose goal is to write the population for https://www.wikidata.org/wiki/Q985476 (only at the moment) per year, which can be found here: https://drive.google.com/drive/folders/1s5ypAGF3u_PGtj9gyIkR7v0CCWdHBUNy?usp=sharing. When running the script I actually get 3 Warnings;

WARNING: /home/edson/Bureau/core/pywikibot/site.py:1331: _NotImplementedWarning: claim without on_item set is deprecated.

  return fn(self, *args, **kwargs)

WARNING: /home/edson/Bureau/core/pywikibot/site.py:1331: UserWarning: Neither claim.on_item nor baserevid provided

  return fn(self, *args, **kwargs)

WARNING: API error noclaim: The "claim" parameter must be set.

Traceback (most recent call last):

  File "pwb.py", line 263, in <module>

   if not main():

  File "pwb.py", line 256, in main

   run_python_file(filename, [filename] + args, argvu, file_package)

  File "pwb.py", line 120, in run_python_file

   main_mod.__dict__)

  File "./addPopulation.py", line 38, in <module>

   populationClaim.addQualifier(qualifier)

  File "/home/edson/Bureau/core/pywikibot/page.py", line 5002, in addQualifier

   data = self.repo.editQualifier(self, qualifier, **kwargs)

  File "/home/edson/Bureau/core/pywikibot/site.py", line 1331, in callee

   return fn(self, *args, **kwargs)

  File "/home/edson/Bureau/core/pywikibot/site.py", line 7813, in editQualifier

   data = req.submit()

  File "/home/edson/Bureau/core/pywikibot/data/api.py", line 2195, in submit

   raise APIError(**result['error'])

pywikibot.data.api.APIError: noclaim: The "claim" parameter must be set. [help:See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes.]

<class 'pywikibot.data.api.APIError'>

CRITICAL: Closing network session.

What am I doing wrong?

Dvorapa (talkcontribs)
Matěj Suchánek (talkcontribs)

How does your code look like?

Soued031 (talkcontribs)
Matěj Suchánek (talkcontribs)

Oops, I see now.

The solution is to move the bottom line (item.addClaim) just before # add qualifier to claim.

Soued031 (talkcontribs)

@Matěj Suchánek Great it works! Thanks for the fast answer. Do I need to do something special to ask for bot rights?

Matěj Suchánek (talkcontribs)

If you want to run a bot on Wikidata, I strongly recommend you requesting the flag at d:WD:RFBOT.

Soued031 (talkcontribs)

Thanks I will look at it.