Additionally, please do not commit commented code: +# if len(data) == 2: +# data = data[0] + data[1] +# else: +# data = data[0]
as it is unclear what the purpose is (testing?)
However, thanks for your efforts. Consider switching to the rewrite branch, though. There is no need to add API queries to the main framework.
Best regards, Merlijn 'valhallasw' van Deen
On 4 May 2010 00:08, Merlijn van Deen valhallasw@arctus.nl wrote:
This e-mail was sent by Maarten to the pywikipedia-svn mailing list.
---------- Forwarded message ---------- From: Maarten Dammers maarten@mdammers.nl To: pywikipedia-svn@lists.wikimedia.org Date: Mon, 03 May 2010 23:15:47 +0200 Subject: Re: [Pywikipedia-svn] SVN: [8136] trunk/pywikipedia/wikipedia.py
This change is incorrect. Categories() should return Page objects, not Unicode objects. Could you please fix this?
Maarten
Op 28-4-2010 22:29, shizhao@svn.wikimedia.org schreef:
Revision: 8136
Author: shizhao Date: 2010-04-28 20:29:31 +0000 (Wed, 28 Apr 2010)
Log Message:
categories() new add API query.
Modified Paths:
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
--- trunk/pywikipedia/wikipedia.py 2010-04-28 14:33:06 UTC (rev 8135) +++ trunk/pywikipedia/wikipedia.py 2010-04-28 20:29:31 UTC (rev 8136) @@ -2173,12 +2173,50 @@ category links in the page text.
"""
try:
category_links_to_return =
getCategoryLinks(self.get(get_redirect=get_redirect), self.site())
except NoPage:
category_links_to_return = []
return category_links_to_return
+# New add API query.
+# api.php?action=query&prop=categories&titles=Albert%20Einstein
+#
if not self.site().has_api():
try:
category_links_to_return =
getCategoryLinks(self.get(get_redirect=get_redirect), self.site())
except NoPage:
category_links_to_return = []
return category_links_to_return
params = {
'action': 'query',
'prop' : 'categories',
'titles' : self.title(),
}
if not self.site().isAllowed('apihighlimits') and
config.special_page_limit> 500:
params['cllimit'] = 500
allDone = False
cats=[]
while not allDone:
output(u'Getting categories in %s via API...' %
self.aslink())
datas = query.GetData(params, self.site())
data=datas['query']['pages'].values()[0]
if "categories" in data:
for c in data['categories']:
cats.append(c['title'])
+# if len(data) == 2: +# data = data[0] + data[1] +# else: +# data = data[0]
if 'query-continue' in datas:
if 'categories' in datas['query-continue']:
params['clcontinue'] =
datas['query-continue']['categories']['clcontinue']
else:
allDone = True
return cats
- def __cmp__(self, other): """Test for equality and inequality of Page objects""" if not isinstance(other, Page):
Pywikipedia-svn mailing list Pywikipedia-svn@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn
---------- Forwarded message ---------- From: pywikipedia-svn-request@lists.wikimedia.org To: Date: Subject: confirm 5757ba7a08bb8766eda2b6838461d7dd08516048 If you reply to this message, keeping the Subject: header intact, Mailman will discard the held message. Do this if the message is spam. If you reply to this message and include an Approved: header with the list password in it, the message will be approved for posting to the list. The Approved: header can also appear in the first line of the body of the reply.