Finally the bug is solved. you can get and set items on wikidata via PWB
At first you must define a wikidataPage and these are methods you can use. I'll try to expand and make more methods but i don't know any and your help will be very useful: Supports the same interface as Page, with the following added methods:
setitem : Setting item(s) on a page
getentity : Getting item(s) of a page
these examples worked for me:
site=wikipedia.getSite('wikidata',fam='wikidata') page=wikipedia.wikidataPage(site,"Helium") text=page.getentity() page.setitem(summary=u"BOT: TESTING FOO",items={'type':u'item', 'label':'fa', 'value':'OK'}) page.setitem(summary=u"BOT: TESTING GOO",items={'type':u'description', 'language':'en', 'value':'OK'}) page.setitem(summary=u"BOT: TESTING BOO",items={'type':u'sitelink', 'site':'de', 'title':'BAR'})
Cheers!
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Update for pywikibot trunk wikidata interface:
Supports the same interface as Page, with the following added methods:
setitem : Setting item(s) on a page setclaimvalue : Set the value of a Wikibase claim createclaim : Create Wikibase claims
getentity : Getting item(s) of a page getentities : Get the data for multiple Wikibase entities
I added the methods: setclaimvalue, createclaim and getentities in order to start including wikidata support to subster.py
Some comments on this: 1.) the methods should be renamed in order to refrect the naming from rewrite which is "get_xxx" and "set_xxx". 2.) the class wikidataPage works clearly with items like "Q356" too and not only with titles/lables like "Helium" like suggested multiple times (the "Q" syntax is clearly preferred since unique) 3.) getentities is in fact the same as getentity as far as I understand but I was not able to get it working nor understand it (to elaborated for me... ;) and thus I decided to start another very simple implementation. (sorry!) 4.) setclaimvalue is in fact not dependent on a page but on a guid only and thus could be moved out of the wikidataPage class.
Thanks to all the inital work done here by amir and others! Hope we can implement more useful stuff here and coordinate the work in order to get a consistent interface.
Thanks and greetings DrTrigon
ps.: http://www.mediawiki.org/wiki/Manual:Pywikipediabot/Wikidata
On 10.12.2012 22:43, Amir Ladsgroup wrote:
Finally the bug is solved. you can get and set items on wikidata via PWB
At first you must define a wikidataPage and these are methods you can use. I'll try to expand and make more methods but i don't know any and your help will be very useful: Supports the same interface as Page, with the following added methods:
setitem : Setting item(s) on a page
getentity : Getting item(s) of a page
these examples worked for me:
site=wikipedia.getSite('wikidata',fam='wikidata') page=wikipedia.wikidataPage(site,"Helium") text=page.getentity() page.setitem(summary=u"BOT: TESTING FOO",items={'type':u'item', 'label':'fa', 'value':'OK'}) page.setitem(summary=u"BOT: TESTING GOO",items={'type':u'description', 'language':'en', 'value':'OK'}) page.setitem(summary=u"BOT: TESTING BOO",items={'type':u'sitelink', 'site':'de', 'title':'BAR'})
Cheers!