https://bugzilla.wikimedia.org/show_bug.cgi?id=60021
Web browser: --- Bug ID: 60021 Summary: addSource and addQualifier return API error Product: Pywikibot Version: core (2.0) Hardware: PC OS: Linux Status: UNCONFIRMED Severity: normal Priority: Unprioritized Component: Wikidata Assignee: Pywikipedia-bugs@lists.wikimedia.org Reporter: kvardek_du@hotmail.fr Classification: Unclassified Mobile Platform: ---
item.addClaim(claim) perfectly works, but claim.addSource and claim.addQualifier return API error :
File "pwb.py", line 135, in <module> run_python_file(fn, argv, argvu) File "pwb.py", line 67, in run_python_file exec(compile(source, filename, "exec"), main_mod.__dict__) File "cc.py", line 39, in <module> claim.addQualifier(date) File "/home/marin/appliext/kun2/data/pywikibot/page.py", line 3017, in addQualifier data = self.repo.editQualifier(self, qualifier, **kwargs) File "/home/marin/appliext/kun2/data/pywikibot/site.py", line 720, in callee return fn(self, *args, **kwargs) File "/home/marin/appliext/kun2/data/pywikibot/site.py", line 3850, in editQualifier data = req.submit() File "/home/marin/appliext/kun2/data/pywikibot/data/api.py", line 401, in submit raise APIError(code, info, **result["error"]) pywikibot.data.api.APIError: invalid-guid: Invalid claim guid
__version__ = '$Id: 2949fa22477edd2b209076d43b2ac1ef9575ff20 $' (downloaded in early january)
code : # -*- coding: utf-8 -*- import pywikibot import pickle import sys wpcom=unicode(sys.argv[1], 'utf-8') wpcc=unicode(sys.argv[2], 'utf-8') site = pywikibot.Site("fr", "wikipedia") page = pywikibot.Page(site, wpcom) pagecc = pywikibot.Page(site, wpcc) item = pywikibot.ItemPage.fromPage(page) itemcc = pywikibot.ItemPage.fromPage(pagecc) site = pywikibot.Site("wikidata", "wikidata") repo = site.data_repository() dictionary = item.get() dictionarycc = itemcc.get() verif=dictionarycc['labels']['fr'] print "La commune est située dans la ", verif #création de la déclaration principale (claim) claim = pywikibot.Claim(repo, u'P131') claim.setTarget(itemcc) print claim date = pywikibot.Claim(repo, u'P585') wikidatevrai = pywikibot.WbTime(year=2013, month=1, day=1) print "wikidatevrai :", wikidatevrai date.setTarget(wikidatevrai) tmp=date.getTarget() print "tmp", tmp print "date :", date claim.addQualifier(date) print claim #création de la source source1 = pywikibot.Claim(repo, u'P854') source1.setTarget(u'Q2981593') #qualificateur pour la source (?) qualif1 = pywikibot.Claim(repo, u'P357') qualif1.setTarget(u'base des EPCI à fiscalité propre au 1er janvier 2013') #source1.addQualifier(qualif1) qualif2 = pywikibot.Claim(repo, u'P577') wikidatecons=pywikibot.WbTime(year=2013, month=8, day=28) print wikidatecons qualif2.setTarget(wikidatecons) #source1.addQualifier(qualif2) #claim.addSources(source1) item.addClaim(claim)
Thank you.
https://bugzilla.wikimedia.org/show_bug.cgi?id=60021
kvardek_du@hotmail.fr changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED
--- Comment #1 from kvardek_du@hotmail.fr --- bot=True was missing in addQualifier in page.py and I did an error while using addSource.
pywikipedia-bugs@lists.wikimedia.org