[Pywikipedia-l] SVN: [6080] trunk/pywikipedia/wikipedia.py
filnik at svn.wikimedia.org
filnik at svn.wikimedia.org
Sat Nov 8 13:40:18 UTC 2008
Revision: 6080
Author: filnik
Date: 2008-11-08 13:40:18 +0000 (Sat, 08 Nov 2008)
Log Message:
-----------
Bugfix for ko.wiki
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-11-08 13:39:53 UTC (rev 6079)
+++ trunk/pywikipedia/wikipedia.py 2008-11-08 13:40:18 UTC (rev 6080)
@@ -913,7 +913,7 @@
x = self.get()
return True # if we reach this point, we had no problems.
- def getTemplates(self):
+ def getTemplates(self, tllimit = 5000):
#action=query&prop=templates&titles=Main Page
"""
Returns the templates that are used in the page given.
@@ -929,13 +929,19 @@
'action' :'query',
'prop' :'templates',
'titles' :self.title(),
- 'tllimit' :5000
+ 'tllimit' :tllimit,
}
data = query.GetData(params,
useAPI = True, encodeTitle = False)
- pageid = data['query']['pages'].keys()[0]
try:
+ pageid = data['query']['pages'].keys()[0]
+ except KeyError:
+ if tllimit != 500:
+ return self.getTemplates(500)
+ else:
+ raise Error(data)
+ try:
templates = data['query']['pages'][pageid]['templates']
except KeyError:
return list()
More information about the Pywikipedia-l
mailing list