Revision: 5265 Author: russblau Date: 2008-04-23 16:41:38 +0000 (Wed, 23 Apr 2008)
Log Message: ----------- check for NotImplementedError whenever using API
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2008-04-23 15:48:15 UTC (rev 5264) +++ trunk/pywikipedia/wikipedia.py 2008-04-23 16:41:38 UTC (rev 5265) @@ -1139,7 +1139,11 @@ ('autoconfirmed' or 'sysop') * expiry is the expiration time of the restriction """ - api_url = self.site().api_address() + restrictions = { 'edit': None, 'move': None } + try: + api_url = self.site().api_address() + except NotImplementedError: + return restrictions api_url += 'action=query&prop=info&inprop=protection&format=xml&titles=%s' % self.urlname() text = self.site().getUrl(api_url) if 'missing=""' in text: @@ -1150,7 +1154,6 @@ # We may want to have better error handling raise Error("BUG> API problem.") match = re.findall(r'<protection>(.*?)</protection>', text) - restrictions = { 'edit': None, 'move': None }
if match: text = match[0] # If there's the block "protection" take the settings inside it.