Bugs item #3601826, was opened at 2013-01-22 15:02 Message generated for change (Settings changed) made by xqt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3601826...
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: other Group: None
Status: Closed Resolution: Rejected
Priority: 5 Private: No Submitted By: Luca Rabinelli (beta16)
Assigned to: xqt (xqt)
Summary: WikiData: DataPage.get() return wrong item
Initial Comment: Hi! page = pywikibot.DataPage(site, 'Univers') returns Q2 correctly but page = pywikibot.DataPage(site, 'Q2') returns Q404776 because label is "Q2"
API wbgetentities can be call by item ID or by sites+titles (https://www.wikidata.org/w/api.php) so I think also Data.Page.get() can be call with 1 parameter -> by item ID: pywikibot.DataPage('Q2') -> return item Q2, label "Univers" with 2 parameters -> by sites+titles: pywikibot.DataPage(site, 'Q2') -> return item Q404776, label "Q2" od define two methods "ByID" and "BySitesTitles".
I hope I explained clearly.
Pywikipedia [http] trunk/pywikipedia (r10965, 2013/01/21, 09:12:28, OUTDATED) Python 2.7.1 (r271:86832, Jan 4 2011, 13:57:14) [GCC 4.5.2] config-settings: use_api = True use_api_login = True unicode test: ok
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2013-01-23 04:53
Message: You are wrong. If the site is not the data repository, it returns the page of the corresponding language link. Samples:
import wikipedia as wp site = wp.getSite('en') repo = site.data_repository() #the wikidata site
# "Univers" at en-wiki gives the corresponding data page "Q1065215"
dp = wp.DataPage(site, 'Univers') data = dp.get() dp
DataPage{[[wikidata:q1065215]]}
# "Q2" at en-wiki gives the corresponding data page "Q404776"
data = wp.DataPage(site, 'Q2') dp = wp.DataPage(site, 'Q2') data = dp.get() dp
DataPage{[[wikidata:q404776]]}
# "Q2" at wikidata is ok:
dp = wp.DataPage(repo, 'Q2') data = dp.get() dp
DataPage{[[wikidata:Q2]]}
# "Univers" at wikidata does not exist and gives an error
dp = wp.DataPage(repo, 'Univers') data = dp.get()
Traceback (most recent call last): File "<pyshell#34>", line 1, in <module> data = dp.get() File "wikipedia.py", line 4406, in get pagetext = super(DataPage, self).get(*args, **kwargs) File "wikipedia.py", line 719, in get expandtemplates = expandtemplates) File "wikipedia.py", line 799, in _getEditPage "Page does not exist. In rare cases, if you are certain the page does exist, look into overriding family.RversionTab") NoPage: (wikidata:wikidata, u'[[wikidata:Univers]]', 'Page does not exist. In rare cases, if you are certain the page does exist, look into overriding family.RversionTab')
dp
DataPage{[[wikidata:Univers]]}
----------------------------------------------------------------------
You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3601826...