Revision: 7094 Author: alexsh Date: 2009-07-25 16:32:24 +0000 (Sat, 25 Jul 2009)
Log Message: ----------- comment out solveCaptcha API...still testing about type() UnboundLocalError
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2009-07-25 09:39:25 UTC (rev 7093) +++ trunk/pywikipedia/wikipedia.py 2009-07-25 16:32:24 UTC (rev 7094) @@ -1680,6 +1680,7 @@
# We might have been prompted for a captcha if the # account is not autoconfirmed, checking.... + output('%s' % data) solve = self.site().solveCaptcha(data) if solve: return self._putPage(text, comment, watchArticle, minorEdit, newPage, token, newToken, sysop, captcha=solve) @@ -4599,20 +4600,20 @@ return '&'.join(l)
def solveCaptcha(self, data): - if type(data) == dict: # API Mode result - if data['result'].has_key("captcha"): - type = data['result']['captcha']['type'] - id = data['result']['captcha']['id'] - if type in ['simple', 'math', 'question']: - answer = input('What is the answer to the captcha "%s" ?' % data['result']['captcha']['question']) - elif type == 'image': - url = self.protocol() + '://' + self.hostname() + self.captcha_image_address(id) - answer = ui.askForCaptcha(url) - else: #no captcha id result, maybe ReCaptcha. - raise CaptchaError('We have been prompted for a ReCaptcha, but pywikipedia does not yet support ReCaptchas') - return {'id':id, 'answer':answer} - return None - else: + #if (type(data) == dict): # API Mode result + # if data['result'].has_key("captcha"): + # type = data['result']['captcha']['type'] + # id = data['result']['captcha']['id'] + # if type in ['simple', 'math', 'question']: + # answer = input('What is the answer to the captcha "%s" ?' % data['result']['captcha']['question']) + # elif type == 'image': + # url = self.protocol() + '://' + self.hostname() + self.captcha_image_address(id) + # answer = ui.askForCaptcha(url) + # else: #no captcha id result, maybe ReCaptcha. + # raise CaptchaError('We have been prompted for a ReCaptcha, but pywikipedia does not yet support ReCaptchas') + # return {'id':id, 'answer':answer} + # return None + #else: captchaW = re.compile('<label for="wpCaptchaWord">(?P<question>[^<]*)</label>') captchaR = re.compile('<input type="hidden" name="wpCaptchaId" id="wpCaptchaId" value="(?P<id>\d+)" />') match = captchaR.search(data)