Hi everyone I added wikidata edits on PWB. for now it's basic and you can only change or add or remove labels but i have plan to imporve it.
You can add wikidata family to your user-config.py and run a simillar code:
import wikipedia site=wikipedia.getSite('wikidata',fam='wikidata') page=wikipedia.Page(site,"Q321") page.put(u"",u"Bot: testing",wikidata=True,labelwikidata=u"no",valuewikidata=u"Test FOO")
I ran that and it workedhttp://wikidata-test-repo.wikimedia.de/w/index.php?title=Q321&curid=9133&diff=105698&oldid=105697but if there is any bugs feel free to tell me
Cheers
Sorry about typos. I haven't slept for two days i think :)
On Sat, Oct 20, 2012 at 8:48 AM, Amir Ladsgroup ladsgroup@gmail.com wrote:
Hi everyone I added wikidata edits on PWB. for now it's basic and you can only change or add or remove labels but i have plan to imporve it.
You can add wikidata family to your user-config.py and run a simillar code:
import wikipedia site=wikipedia.getSite('wikidata',fam='wikidata') page=wikipedia.Page(site,"Q321") page.put(u"",u"Bot: testing",wikidata=True,labelwikidata=u"no",valuewikidata=u"Test FOO")
I ran that and it workedhttp://wikidata-test-repo.wikimedia.de/w/index.php?title=Q321&curid=9133&diff=105698&oldid=105697but if there is any bugs feel free to tell me
Cheers
Amir
The following is a small sample just for reading a wikidata entry:
trunk version: import wikipedia as wp s = wp.getSite('wikidata', 'wikidata') p = wp.Page(s, 'Q321') data = eval(p.get()) # evaluation is needed for transform text into dictionary
data is a data dictionary. Try data.keys() for the data keys which are
['statements', 'description', 'links', 'entity', 'label', 'aliases']
rewrite branch: # The family file was introduced one month ago and has different language codes. 'repro' is for the repository. import pwb import pywikibot as wp s = wp.getSite('repro', 'wikidata') p = wp.Page(s, 'Q321') data = eval(p.get()) data.keys()
have fun with playing with that information xqt
----- Original Nachricht ---- Von: Amir Ladsgroup ladsgroup@gmail.com An: Pywikipedia discussion list pywikipedia-l@lists.wikimedia.org Datum: 20.10.2012 07:18 Betreff: [Pywikipedia-l] Wikidata
Hi everyone I added wikidata edits on PWB. for now it's basic and you can only change or add or remove labels but i have plan to imporve it.
You can add wikidata family to your user-config.py and run a simillar code:
import wikipedia site=wikipedia.getSite('wikidata',fam='wikidata') page=wikipedia.Page(site,"Q321") page.put(u"",u"Bot: testing",wikidata=True,labelwikidata=u"no",valuewikidata=u"Test FOO")
I ran that and it workedhttp://wikidata-test-repo.wikimedia.de/w/index.php?title=Q321&curid=9 133&diff=105698&oldid=105697but if there is any bugs feel free to tell me
Cheers
Amir
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
I changed again and the code runs if you run it this way: import wikipedia site=wikipedia.getSite('wikidata',fam='wikidata') page=wikipedia.Page(site,"Helium") page.put(u"",u"BOT: TESTING FOO",wikidata={'type':u'item', 'label':'fa', 'value':'OK'}) page.put(u"",u"BOT: TESTING GOO",wikidata={'type':u'description', 'language':'en', 'value':'OK'})
You just need title now and you can change labels or description I'm working on changing sitelinks
I must thank John Blad, He helped me very kindly
On Sat, Oct 20, 2012 at 3:19 PM, info@gno.de wrote:
The following is a small sample just for reading a wikidata entry:
trunk version: import wikipedia as wp s = wp.getSite('wikidata', 'wikidata') p = wp.Page(s, 'Q321') data = eval(p.get()) # evaluation is needed for transform text into dictionary
data is a data dictionary. Try data.keys() for the data keys which are
['statements', 'description', 'links', 'entity', 'label', 'aliases']
rewrite branch: # The family file was introduced one month ago and has different language codes. 'repro' is for the repository. import pwb import pywikibot as wp s = wp.getSite('repro', 'wikidata') p = wp.Page(s, 'Q321') data = eval(p.get()) data.keys()
have fun with playing with that information xqt
----- Original Nachricht ---- Von: Amir Ladsgroup ladsgroup@gmail.com An: Pywikipedia discussion list pywikipedia-l@lists.wikimedia.org Datum: 20.10.2012 07:18 Betreff: [Pywikipedia-l] Wikidata
Hi everyone I added wikidata edits on PWB. for now it's basic and you can only change or add or remove labels but i have plan to imporve it.
You can add wikidata family to your user-config.py and run a simillar
code:
import wikipedia site=wikipedia.getSite('wikidata',fam='wikidata') page=wikipedia.Page(site,"Q321") page.put(u"",u"Bot: testing",wikidata=True,labelwikidata=u"no",valuewikidata=u"Test FOO")
I ran that and it worked<
http://wikidata-test-repo.wikimedia.de/w/index.php?title=Q321&curid=9
133&diff=105698&oldid=105697>but if there is any bugs feel free to tell me
Cheers
Amir
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
2012/10/20 info@gno.de
The following is a small sample just for reading a wikidata entry:
trunk version: import wikipedia as wp s = wp.getSite('wikidata', 'wikidata') p = wp.Page(s, 'Q321') data = eval(p.get()) # evaluation is needed for transform text into dictionary
This does not work for me, with the latest revision: Traceback (most recent call last): File "C:\Pywikipedia\wikidata-teszt.py", line 4, in <module> data = eval(p.get()) # evaluation is needed for transform text into dictionary File "C:\Pywikipedia\wikipedia.py", line 697, in get expandtemplates = expandtemplates) File "C:\Pywikipedia\wikipedia.py", line 778, in _getEditPage data['query']={'pages':data['entities']} KeyError: 'entities'
I think there must be some change with the API, please compare http://wikidata-test-repo.wikimedia.de/w/api.php to https://www.wikidata.org/w/api.php Could someone find the problem please?
B.
you can see the discussion here: https://www.mediawiki.org/wiki/Special:Code/pywikipedia/10615
On Mon, Nov 12, 2012 at 1:59 AM, Bináris wikiposta@gmail.com wrote:
2012/10/20 info@gno.de
The following is a small sample just for reading a wikidata entry:
trunk version: import wikipedia as wp s = wp.getSite('wikidata', 'wikidata') p = wp.Page(s, 'Q321') data = eval(p.get()) # evaluation is needed for transform text into dictionary
This does not work for me, with the latest revision: Traceback (most recent call last): File "C:\Pywikipedia\wikidata-teszt.py", line 4, in <module>
data = eval(p.get()) # evaluation is needed for transform text into
dictionary File "C:\Pywikipedia\wikipedia.py", line 697, in get expandtemplates = expandtemplates) File "C:\Pywikipedia\wikipedia.py", line 778, in _getEditPage data['query']={'pages':data['entities']} KeyError: 'entities'
I think there must be some change with the API, please compare http://wikidata-test-repo.wikimedia.de/w/api.php to https://www.wikidata.org/w/api.php Could someone find the problem please?
B.
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
Thanks, I suspected something like that. I changed wbentities to wbitems and entities to items in wikipedia.py 761-793, but got a NoPage error for an existing page. So probably the best thing is to wait for Wikidata being updated?
2012/11/11 Amir Ladsgroup ladsgroup@gmail.com
you can see the discussion here: https://www.mediawiki.org/wiki/Special:Code/pywikipedia/10615
On Mon, Nov 12, 2012 at 1:59 AM, Bináris wikiposta@gmail.com wrote:
2012/10/20 info@gno.de
The following is a small sample just for reading a wikidata entry:
trunk version: import wikipedia as wp s = wp.getSite('wikidata', 'wikidata') p = wp.Page(s, 'Q321') data = eval(p.get()) # evaluation is needed for transform text into dictionary
This does not work for me, with the latest revision: Traceback (most recent call last): File "C:\Pywikipedia\wikidata-teszt.py", line 4, in <module>
data = eval(p.get()) # evaluation is needed for transform text into
dictionary File "C:\Pywikipedia\wikipedia.py", line 697, in get expandtemplates = expandtemplates) File "C:\Pywikipedia\wikipedia.py", line 778, in _getEditPage data['query']={'pages':data['entities']} KeyError: 'entities'
I think there must be some change with the API, please compare http://wikidata-test-repo.wikimedia.de/w/api.php to https://www.wikidata.org/w/api.php Could someone find the problem please?
B.
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
-- Amir
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
Wikidata was updated this evening, but my bot still does not work with the newest pywiki in main namespace. No problem with classic MediaWiki namespaces. Can someone provide a piece of working code to read and write an item?
2012/11/11 Bináris wikiposta@gmail.com
Thanks, I suspected something like that. I changed wbentities to wbitems and entities to items in wikipedia.py 761-793, but got a NoPage error for an existing page. So probably the best thing is to wait for Wikidata being updated?
2012/11/11 Amir Ladsgroup ladsgroup@gmail.com
you can see the discussion here: https://www.mediawiki.org/wiki/Special:Code/pywikipedia/10615
On Mon, Nov 12, 2012 at 1:59 AM, Bináris wikiposta@gmail.com wrote:
2012/10/20 info@gno.de
The following is a small sample just for reading a wikidata entry:
trunk version: import wikipedia as wp s = wp.getSite('wikidata', 'wikidata') p = wp.Page(s, 'Q321') data = eval(p.get()) # evaluation is needed for transform text into dictionary
This does not work for me, with the latest revision: Traceback (most recent call last): File "C:\Pywikipedia\wikidata-teszt.py", line 4, in <module>
data = eval(p.get()) # evaluation is needed for transform text into
dictionary File "C:\Pywikipedia\wikipedia.py", line 697, in get expandtemplates = expandtemplates) File "C:\Pywikipedia\wikipedia.py", line 778, in _getEditPage data['query']={'pages':data['entities']} KeyError: 'entities'
I think there must be some change with the API, please compare http://wikidata-test-repo.wikimedia.de/w/api.php to https://www.wikidata.org/w/api.php Could someone find the problem please?
B.
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
-- Amir
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
-- Bináris
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 20.10.2012 13:49, info@gno.de wrote:
data = eval(p.get())
...may be it's safer to use the json module instead of a plain (and powerful! ;) 'eval' in several places:
import json data = json.loads(p.get())
or at least the secured ast eval:
import ast data = ast.literal_eval(p.get())
Any other optinions on this?
Thanks and greetings DrTrigon
pywikipedia-l@lists.wikimedia.org