Bugs item #3606192, was opened at 2013-02-27 02:18
Message generated for change (Comment added) made by reza1615
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
Summary: update wikipdata's item one time!
Initial Comment:
Now if we want add data below we should edit item 5 times! it will crowded and messy the history (imagine updating item with 60 interwikis!)
lang:en >label:foo
lang:de >label:foo
lang:fa >label:foo
labe:ru >label:foo
lang:nl >;abel foo
setitem should accept item in this style
items=[{lang:en,label:foo},{lang:de,label:foo},{lang:fa,label:foo},{lang:ru,label:foo},{lang:nl,label:foo}]
also for wikilinks and descriptions and aliases.
----------------------------------------------------------------------
>Comment By: reza (reza1615)
Date: 2013-02-27 03:40
Message:
http://www.wikidata.org/w/index.php?title=Q794445&diff=7988999&oldid=7987394
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-27 03:19
Message:
it lets !
http://www.wikidata.org/w/index.php?title=Q794445&diff=prev&oldid=7984899
done by api with [[mediawiki:gadget-slurpInterwiki.js]]
----------------------------------------------------------------------
Comment By: Amir (amird)
Date: 2013-02-27 02:50
Message:
http://wikidata.org/w/api.php
API doesn't let changing of an existing item at once
About creating it's possible
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Bugs item #3606192, was opened at 2013-02-27 02:18
Message generated for change (Comment added) made by reza1615
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
Summary: update wikipdata's item one time!
Initial Comment:
Now if we want add data below we should edit item 5 times! it will crowded and messy the history (imagine updating item with 60 interwikis!)
lang:en >label:foo
lang:de >label:foo
lang:fa >label:foo
labe:ru >label:foo
lang:nl >;abel foo
setitem should accept item in this style
items=[{lang:en,label:foo},{lang:de,label:foo},{lang:fa,label:foo},{lang:ru,label:foo},{lang:nl,label:foo}]
also for wikilinks and descriptions and aliases.
----------------------------------------------------------------------
>Comment By: reza (reza1615)
Date: 2013-02-27 03:19
Message:
it lets !
http://www.wikidata.org/w/index.php?title=Q794445&diff=prev&oldid=7984899
done by api with [[mediawiki:gadget-slurpInterwiki.js]]
----------------------------------------------------------------------
Comment By: Amir (amird)
Date: 2013-02-27 02:50
Message:
http://wikidata.org/w/api.php
API doesn't let changing of an existing item at once
About creating it's possible
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Bugs item #3606192, was opened at 2013-02-27 02:18
Message generated for change (Comment added) made by amird
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
Summary: update wikipdata's item one time!
Initial Comment:
Now if we want add data below we should edit item 5 times! it will crowded and messy the history (imagine updating item with 60 interwikis!)
lang:en >label:foo
lang:de >label:foo
lang:fa >label:foo
labe:ru >label:foo
lang:nl >;abel foo
setitem should accept item in this style
items=[{lang:en,label:foo},{lang:de,label:foo},{lang:fa,label:foo},{lang:ru,label:foo},{lang:nl,label:foo}]
also for wikilinks and descriptions and aliases.
----------------------------------------------------------------------
Comment By: Amir (amird)
Date: 2013-02-27 02:50
Message:
http://wikidata.org/w/api.php
API doesn't let changing of an existing item at once
About creating it's possible
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Bugs item #3606192, was opened at 2013-02-27 02:18
Message generated for change (Settings changed) made by reza1615
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
>Summary: update wikipdata's item one time!
Initial Comment:
Now if we want add data below we should edit item 5 times! it will crowded and messy the history (imagine updating item with 60 interwikis!)
lang:en >label:foo
lang:de >label:foo
lang:fa >label:foo
labe:ru >label:foo
lang:nl >;abel foo
setitem should accept item in this style
items=[{lang:en,label:foo},{lang:de,label:foo},{lang:fa,label:foo},{lang:ru,label:foo},{lang:nl,label:foo}]
also for wikilinks and descriptions and aliases.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Bugs item #3606192, was opened at 2013-02-27 02:18
Message generated for change (Tracker Item Submitted) made by reza1615
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
Summary: update wikipdata's items one time!
Initial Comment:
Now if we want add data below we should edit item 5 times! it will crowded and messy the history (imagine updating item with 60 interwikis!)
lang:en >label:foo
lang:de >label:foo
lang:fa >label:foo
labe:ru >label:foo
lang:nl >;abel foo
setitem should accept item in this style
items=[{lang:en,label:foo},{lang:de,label:foo},{lang:fa,label:foo},{lang:ru,label:foo},{lang:nl,label:foo}]
also for wikilinks and descriptions and aliases.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3606192&group_…
Bugs item #3605830, was opened at 2013-02-24 11:21
Message generated for change (Comment added) made by reza1615
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
Summary: setitem for wikidata doesn't work!
Initial Comment:
I used this code
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'آبشار لاتون,آبشار لاتون'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
data.setitem(summary,items={'type': u'item', 'label': 'glk', 'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk', 'title':u'آبشار_لاتون_(بارزاو)'})
it shows
Updating page [[wikidata:Q5058182]] via API
Updating page [[wikidata:Q5058182]] via API
but it doesn't update the page!
also please add
def getIdFromPage(data)
id=data.get() ['entity'].replace('q','')
return id
and add
data = DataPage(site.data_repository(), "Q"+id)
to first line of setitem()
----------------------------------------------------------------------
>Comment By: reza (reza1615)
Date: 2013-02-27 02:11
Message:
when we write
my_data = wp.DataPage(p)
my_data should contained item!
now for loading data to my_data we shod type .get() or .exist() which are
not necessary
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-26 22:17
Message:
How could you update an item without knowing its content?
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 11:51
Message:
in this report I don't want to make an item!
I know about making an item amir solved it in last report
(https://www.mediawiki.org/wiki/Special:Code/pywikipedia/11103)
Now I want update an item with wikipedia.py
for updating an item we should call data object with .get() or .exists() or
other functions to let wikipedia.py load that data object and it is not
good because user should write 4 lines in every part of his code
you can add these lines to library to not repeating.
for setitem() you can add
if d.exists():
pass # pass or doing next lines
else:
print 'page not exist do you want creat it? '# or it can call creatitem()
function if user allowed bot to create not existed item
for createitem() you can add
if d.exists():
print 'page exists so creating process is aborted?'# or we can ask user do
you want overwrite?
else:
pass # pass or doing next lines
it should be done by library not users. because minimal coding is much
better than writing repeated lines!
if I want to create or edit an item I should add these 4 lines to my code
but if they are inside wikipedia.py we don't need to write them.
it makes easy for coding . now calling .get() or .exists() is tricky
and every user don't know and they will have problem with this!
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-26 10:42
Message:
There are two ways doing that task creating an item; i'll explain it with a
pseudocode:
1st:
repo = repository(localpage)
try: repo.createitem()
except itemExistError: print repo.title(), 'already exist'
2st:
repo = repository(localpage)
if not repo.exists(): repo.createitem()
else: print repo.title(), 'allready exits'
I prefer the last one. Look at this sample:
>>> import wikipedia as wp
>>> p = wp.Page('de', 'Helium')
>>> d = wp.DataPage(p)
>>> d
DataPage{[[wikidata:None]]}
>>> d.exists()
True
>>> d
DataPage{[[wikidata:Q560]]}
>>>
This means you does not need to call DataPage.get() you may also use
DataPage.exists() for this test.
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 05:14
Message:
No! it is not correct !
now user should write
try:
gett=data.get()
except:
some thing to do (may be saying error)
Instead of these four lines library should tell user that item doesn't
exist so code should switch to create a new item.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 05:05
Message:
The line is not useless. If the item doesn't exist you will have an error
instead of doing nothing
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 05:02
Message:
we can load or get data inside setitem()
it is not normal that we type a code that it's variable ( gett=data.get()
) doesn't need! (visually)
it is logic that users only type this code
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label':
'glk','value':u'آبشار_لاتون'})
Library should be let user to type minimal code.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 04:45
Message:
I tested it and it worked:
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7790985
We have showing problem. the code works well
I think xqt means if you run this way the showing problem will be solved.
something like this notice i just add one line:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
gett=data.get()
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 04:32
Message:
please run this code and you will see the none title error !
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 23:38
Message:
This error looks like you haven't made a DataPage.get() before you tried to
update the page. In this cas the title is None as shown. If you recreate
the datapage with the entity id you make a explicit get call to retrieve
the items data. But this will be enough to get the data's id i.e. the
DataPage.title().
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 04:40
Message:
If I don't make in DataPage a second time it will show this error
Updating page [[wikidata:None]] via API
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 03:43
Message:
You don't need to create the DataPage a second time with the 'entity' item.
Look at this sample which shows that data == d but they are different
objects in this sample:
>>> import wikipedia as wp
>>> s = wp.getSite()
>>> p = wp.Page(s, 'Helium')
>>> d = wp.DataPage(p)
>>> i = d.get()
>>> t = i['entity'].title()
>>> data = wp.DataPage(s.data_repository(), t)
>>> data
DataPage{[[wikidata:Q560]]}
>>> d
DataPage{[[wikidata:Q560]]}
>>> d is data
False
>>> d == data
True
>>>
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:35
Message:
three :)
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:34
Message:
Thank you now it works.
please add these tree lines to setitem()
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
now we should write these tree lines for every DataPage()
----------------------------------------------------------------------
Comment By: Amir (amird)
Date: 2013-02-24 21:58
Message:
fixed in r11114
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673026http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673011
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…
Bugs item #3605830, was opened at 2013-02-24 11:21
Message generated for change (Comment added) made by xqt
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
Summary: setitem for wikidata doesn't work!
Initial Comment:
I used this code
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'آبشار لاتون,آبشار لاتون'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
data.setitem(summary,items={'type': u'item', 'label': 'glk', 'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk', 'title':u'آبشار_لاتون_(بارزاو)'})
it shows
Updating page [[wikidata:Q5058182]] via API
Updating page [[wikidata:Q5058182]] via API
but it doesn't update the page!
also please add
def getIdFromPage(data)
id=data.get() ['entity'].replace('q','')
return id
and add
data = DataPage(site.data_repository(), "Q"+id)
to first line of setitem()
----------------------------------------------------------------------
>Comment By: xqt (xqt)
Date: 2013-02-26 22:17
Message:
How could you update an item without knowing its content?
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 11:51
Message:
in this report I don't want to make an item!
I know about making an item amir solved it in last report
(https://www.mediawiki.org/wiki/Special:Code/pywikipedia/11103)
Now I want update an item with wikipedia.py
for updating an item we should call data object with .get() or .exists() or
other functions to let wikipedia.py load that data object and it is not
good because user should write 4 lines in every part of his code
you can add these lines to library to not repeating.
for setitem() you can add
if d.exists():
pass # pass or doing next lines
else:
print 'page not exist do you want creat it? '# or it can call creatitem()
function if user allowed bot to create not existed item
for createitem() you can add
if d.exists():
print 'page exists so creating process is aborted?'# or we can ask user do
you want overwrite?
else:
pass # pass or doing next lines
it should be done by library not users. because minimal coding is much
better than writing repeated lines!
if I want to create or edit an item I should add these 4 lines to my code
but if they are inside wikipedia.py we don't need to write them.
it makes easy for coding . now calling .get() or .exists() is tricky
and every user don't know and they will have problem with this!
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-26 10:42
Message:
There are two ways doing that task creating an item; i'll explain it with a
pseudocode:
1st:
repo = repository(localpage)
try: repo.createitem()
except itemExistError: print repo.title(), 'already exist'
2st:
repo = repository(localpage)
if not repo.exists(): repo.createitem()
else: print repo.title(), 'allready exits'
I prefer the last one. Look at this sample:
>>> import wikipedia as wp
>>> p = wp.Page('de', 'Helium')
>>> d = wp.DataPage(p)
>>> d
DataPage{[[wikidata:None]]}
>>> d.exists()
True
>>> d
DataPage{[[wikidata:Q560]]}
>>>
This means you does not need to call DataPage.get() you may also use
DataPage.exists() for this test.
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 05:14
Message:
No! it is not correct !
now user should write
try:
gett=data.get()
except:
some thing to do (may be saying error)
Instead of these four lines library should tell user that item doesn't
exist so code should switch to create a new item.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 05:05
Message:
The line is not useless. If the item doesn't exist you will have an error
instead of doing nothing
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 05:02
Message:
we can load or get data inside setitem()
it is not normal that we type a code that it's variable ( gett=data.get()
) doesn't need! (visually)
it is logic that users only type this code
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label':
'glk','value':u'آبشار_لاتون'})
Library should be let user to type minimal code.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 04:45
Message:
I tested it and it worked:
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7790985
We have showing problem. the code works well
I think xqt means if you run this way the showing problem will be solved.
something like this notice i just add one line:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
gett=data.get()
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 04:32
Message:
please run this code and you will see the none title error !
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 23:38
Message:
This error looks like you haven't made a DataPage.get() before you tried to
update the page. In this cas the title is None as shown. If you recreate
the datapage with the entity id you make a explicit get call to retrieve
the items data. But this will be enough to get the data's id i.e. the
DataPage.title().
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 04:40
Message:
If I don't make in DataPage a second time it will show this error
Updating page [[wikidata:None]] via API
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 03:43
Message:
You don't need to create the DataPage a second time with the 'entity' item.
Look at this sample which shows that data == d but they are different
objects in this sample:
>>> import wikipedia as wp
>>> s = wp.getSite()
>>> p = wp.Page(s, 'Helium')
>>> d = wp.DataPage(p)
>>> i = d.get()
>>> t = i['entity'].title()
>>> data = wp.DataPage(s.data_repository(), t)
>>> data
DataPage{[[wikidata:Q560]]}
>>> d
DataPage{[[wikidata:Q560]]}
>>> d is data
False
>>> d == data
True
>>>
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:35
Message:
three :)
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:34
Message:
Thank you now it works.
please add these tree lines to setitem()
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
now we should write these tree lines for every DataPage()
----------------------------------------------------------------------
Comment By: Amir (amird)
Date: 2013-02-24 21:58
Message:
fixed in r11114
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673026http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673011
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…
Bugs item #3605830, was opened at 2013-02-24 11:21
Message generated for change (Comment added) made by reza1615
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
Summary: setitem for wikidata doesn't work!
Initial Comment:
I used this code
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'آبشار لاتون,آبشار لاتون'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
data.setitem(summary,items={'type': u'item', 'label': 'glk', 'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk', 'title':u'آبشار_لاتون_(بارزاو)'})
it shows
Updating page [[wikidata:Q5058182]] via API
Updating page [[wikidata:Q5058182]] via API
but it doesn't update the page!
also please add
def getIdFromPage(data)
id=data.get() ['entity'].replace('q','')
return id
and add
data = DataPage(site.data_repository(), "Q"+id)
to first line of setitem()
----------------------------------------------------------------------
>Comment By: reza (reza1615)
Date: 2013-02-26 11:51
Message:
in this report I don't want to make an item!
I know about making an item amir solved it in last report
(https://www.mediawiki.org/wiki/Special:Code/pywikipedia/11103)
Now I want update an item with wikipedia.py
for updating an item we should call data object with .get() or .exists() or
other functions to let wikipedia.py load that data object and it is not
good because user should write 4 lines in every part of his code
you can add these lines to library to not repeating.
for setitem() you can add
if d.exists():
pass # pass or doing next lines
else:
print 'page not exist do you want creat it? '# or it can call creatitem()
function if user allowed bot to create not existed item
for createitem() you can add
if d.exists():
print 'page exists so creating process is aborted?'# or we can ask user do
you want overwrite?
else:
pass # pass or doing next lines
it should be done by library not users. because minimal coding is much
better than writing repeated lines!
if I want to create or edit an item I should add these 4 lines to my code
but if they are inside wikipedia.py we don't need to write them.
it makes easy for coding . now calling .get() or .exists() is tricky
and every user don't know and they will have problem with this!
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-26 10:42
Message:
There are two ways doing that task creating an item; i'll explain it with a
pseudocode:
1st:
repo = repository(localpage)
try: repo.createitem()
except itemExistError: print repo.title(), 'already exist'
2st:
repo = repository(localpage)
if not repo.exists(): repo.createitem()
else: print repo.title(), 'allready exits'
I prefer the last one. Look at this sample:
>>> import wikipedia as wp
>>> p = wp.Page('de', 'Helium')
>>> d = wp.DataPage(p)
>>> d
DataPage{[[wikidata:None]]}
>>> d.exists()
True
>>> d
DataPage{[[wikidata:Q560]]}
>>>
This means you does not need to call DataPage.get() you may also use
DataPage.exists() for this test.
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 05:14
Message:
No! it is not correct !
now user should write
try:
gett=data.get()
except:
some thing to do (may be saying error)
Instead of these four lines library should tell user that item doesn't
exist so code should switch to create a new item.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 05:05
Message:
The line is not useless. If the item doesn't exist you will have an error
instead of doing nothing
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 05:02
Message:
we can load or get data inside setitem()
it is not normal that we type a code that it's variable ( gett=data.get()
) doesn't need! (visually)
it is logic that users only type this code
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label':
'glk','value':u'آبشار_لاتون'})
Library should be let user to type minimal code.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 04:45
Message:
I tested it and it worked:
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7790985
We have showing problem. the code works well
I think xqt means if you run this way the showing problem will be solved.
something like this notice i just add one line:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
gett=data.get()
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 04:32
Message:
please run this code and you will see the none title error !
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 23:38
Message:
This error looks like you haven't made a DataPage.get() before you tried to
update the page. In this cas the title is None as shown. If you recreate
the datapage with the entity id you make a explicit get call to retrieve
the items data. But this will be enough to get the data's id i.e. the
DataPage.title().
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 04:40
Message:
If I don't make in DataPage a second time it will show this error
Updating page [[wikidata:None]] via API
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 03:43
Message:
You don't need to create the DataPage a second time with the 'entity' item.
Look at this sample which shows that data == d but they are different
objects in this sample:
>>> import wikipedia as wp
>>> s = wp.getSite()
>>> p = wp.Page(s, 'Helium')
>>> d = wp.DataPage(p)
>>> i = d.get()
>>> t = i['entity'].title()
>>> data = wp.DataPage(s.data_repository(), t)
>>> data
DataPage{[[wikidata:Q560]]}
>>> d
DataPage{[[wikidata:Q560]]}
>>> d is data
False
>>> d == data
True
>>>
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:35
Message:
three :)
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:34
Message:
Thank you now it works.
please add these tree lines to setitem()
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
now we should write these tree lines for every DataPage()
----------------------------------------------------------------------
Comment By: Amir (amird)
Date: 2013-02-24 21:58
Message:
fixed in r11114
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673026http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673011
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…
Bugs item #3605830, was opened at 2013-02-24 11:21
Message generated for change (Comment added) made by xqt
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
Summary: setitem for wikidata doesn't work!
Initial Comment:
I used this code
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'آبشار لاتون,آبشار لاتون'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
data.setitem(summary,items={'type': u'item', 'label': 'glk', 'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk', 'title':u'آبشار_لاتون_(بارزاو)'})
it shows
Updating page [[wikidata:Q5058182]] via API
Updating page [[wikidata:Q5058182]] via API
but it doesn't update the page!
also please add
def getIdFromPage(data)
id=data.get() ['entity'].replace('q','')
return id
and add
data = DataPage(site.data_repository(), "Q"+id)
to first line of setitem()
----------------------------------------------------------------------
>Comment By: xqt (xqt)
Date: 2013-02-26 10:42
Message:
There are two ways doing that task creating an item; i'll explain it with a
pseudocode:
1st:
repo = repository(localpage)
try: repo.createitem()
except itemExistError: print repo.title(), 'already exist'
2st:
repo = repository(localpage)
if not repo.exists(): repo.createitem()
else: print repo.title(), 'allready exits'
I prefer the last one. Look at this sample:
>>> import wikipedia as wp
>>> p = wp.Page('de', 'Helium')
>>> d = wp.DataPage(p)
>>> d
DataPage{[[wikidata:None]]}
>>> d.exists()
True
>>> d
DataPage{[[wikidata:Q560]]}
>>>
This means you does not need to call DataPage.get() you may also use
DataPage.exists() for this test.
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 05:14
Message:
No! it is not correct !
now user should write
try:
gett=data.get()
except:
some thing to do (may be saying error)
Instead of these four lines library should tell user that item doesn't
exist so code should switch to create a new item.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 05:05
Message:
The line is not useless. If the item doesn't exist you will have an error
instead of doing nothing
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 05:02
Message:
we can load or get data inside setitem()
it is not normal that we type a code that it's variable ( gett=data.get()
) doesn't need! (visually)
it is logic that users only type this code
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label':
'glk','value':u'آبشار_لاتون'})
Library should be let user to type minimal code.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 04:45
Message:
I tested it and it worked:
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7790985
We have showing problem. the code works well
I think xqt means if you run this way the showing problem will be solved.
something like this notice i just add one line:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
gett=data.get()
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 04:32
Message:
please run this code and you will see the none title error !
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 23:38
Message:
This error looks like you haven't made a DataPage.get() before you tried to
update the page. In this cas the title is None as shown. If you recreate
the datapage with the entity id you make a explicit get call to retrieve
the items data. But this will be enough to get the data's id i.e. the
DataPage.title().
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 04:40
Message:
If I don't make in DataPage a second time it will show this error
Updating page [[wikidata:None]] via API
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 03:43
Message:
You don't need to create the DataPage a second time with the 'entity' item.
Look at this sample which shows that data == d but they are different
objects in this sample:
>>> import wikipedia as wp
>>> s = wp.getSite()
>>> p = wp.Page(s, 'Helium')
>>> d = wp.DataPage(p)
>>> i = d.get()
>>> t = i['entity'].title()
>>> data = wp.DataPage(s.data_repository(), t)
>>> data
DataPage{[[wikidata:Q560]]}
>>> d
DataPage{[[wikidata:Q560]]}
>>> d is data
False
>>> d == data
True
>>>
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:35
Message:
three :)
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:34
Message:
Thank you now it works.
please add these tree lines to setitem()
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
now we should write these tree lines for every DataPage()
----------------------------------------------------------------------
Comment By: Amir (amird)
Date: 2013-02-24 21:58
Message:
fixed in r11114
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673026http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673011
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…
Bugs item #3605830, was opened at 2013-02-24 11:21
Message generated for change (Comment added) made by reza1615
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: reza (reza1615)
Assigned to: Nobody/Anonymous (nobody)
Summary: setitem for wikidata doesn't work!
Initial Comment:
I used this code
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'آبشار لاتون,آبشار لاتون'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
data.setitem(summary,items={'type': u'item', 'label': 'glk', 'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk', 'title':u'آبشار_لاتون_(بارزاو)'})
it shows
Updating page [[wikidata:Q5058182]] via API
Updating page [[wikidata:Q5058182]] via API
but it doesn't update the page!
also please add
def getIdFromPage(data)
id=data.get() ['entity'].replace('q','')
return id
and add
data = DataPage(site.data_repository(), "Q"+id)
to first line of setitem()
----------------------------------------------------------------------
>Comment By: reza (reza1615)
Date: 2013-02-26 05:14
Message:
No! it is not correct !
now user should write
try:
gett=data.get()
except:
some thing to do (may be saying error)
Instead of these four lines library should tell user that item doesn't
exist so code should switch to create a new item.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 05:05
Message:
The line is not useless. If the item doesn't exist you will have an error
instead of doing nothing
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 05:02
Message:
we can load or get data inside setitem()
it is not normal that we type a code that it's variable ( gett=data.get()
) doesn't need! (visually)
it is logic that users only type this code
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label':
'glk','value':u'آبشار_لاتون'})
Library should be let user to type minimal code.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2013-02-26 04:45
Message:
I tested it and it worked:
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7790985
We have showing problem. the code works well
I think xqt means if you run this way the showing problem will be solved.
something like this notice i just add one line:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
gett=data.get()
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-26 04:32
Message:
please run this code and you will see the none title error !
#!/usr/bin/python
# -*- coding: utf-8 -*-
import wikipedia,login
summary=u'test bot'
site=wikipedia.getSite('fa',fam='wikipedia')
fapage=wikipedia.Page(site,u'آبشار_لاتون')
data=wikipedia.DataPage(fapage)
data.setitem(summary,items={'type': u'item', 'label': 'glk',
'value':u'آبشار_لاتون'})
data.setitem(summary,items={'type': u'sitelink', 'site': 'glk',
'title':u'آبشار_لاتون_(بارزاو)'})
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 23:38
Message:
This error looks like you haven't made a DataPage.get() before you tried to
update the page. In this cas the title is None as shown. If you recreate
the datapage with the entity id you make a explicit get call to retrieve
the items data. But this will be enough to get the data's id i.e. the
DataPage.title().
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 04:40
Message:
If I don't make in DataPage a second time it will show this error
Updating page [[wikidata:None]] via API
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-02-25 03:43
Message:
You don't need to create the DataPage a second time with the 'entity' item.
Look at this sample which shows that data == d but they are different
objects in this sample:
>>> import wikipedia as wp
>>> s = wp.getSite()
>>> p = wp.Page(s, 'Helium')
>>> d = wp.DataPage(p)
>>> i = d.get()
>>> t = i['entity'].title()
>>> data = wp.DataPage(s.data_repository(), t)
>>> data
DataPage{[[wikidata:Q560]]}
>>> d
DataPage{[[wikidata:Q560]]}
>>> d is data
False
>>> d == data
True
>>>
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:35
Message:
three :)
----------------------------------------------------------------------
Comment By: reza (reza1615)
Date: 2013-02-25 02:34
Message:
Thank you now it works.
please add these tree lines to setitem()
list=data.get()
id=list['entity'].replace('q','')
data = wikipedia.DataPage(site.data_repository(), "Q"+id)
now we should write these tree lines for every DataPage()
----------------------------------------------------------------------
Comment By: Amir (amird)
Date: 2013-02-24 21:58
Message:
fixed in r11114
http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673026http://www.wikidata.org/w/index.php?title=Q5058182&diff=prev&oldid=7673011
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3605830&group_…