2626RE_LOGIN_HASH = re .compile (r'name="lg_h" value="([a-z0-9]+)"' )
2727RE_CAPTCHAID = re .compile (r"onLoginCaptcha\('(\d+)'" )
2828RE_NUMBER_HASH = re .compile (r"al_page: '3', hash: '([a-z0-9]+)'" )
29- RE_AUTH_HASH = re .compile (r"\{.*?act: 'a_authcheck_code'.+?hash: '([a-z_0-9]+)'.*?\}" )
29+ RE_AUTH_HASH = re .compile (
30+ r"\{.*?act: 'a_authcheck_code'.+?hash: '([a-z_0-9]+)'.*?\}"
31+ )
3032RE_TOKEN_URL = re .compile (r'location\.href = "(.*?)"\+addr;' )
3133
3234RE_PHONE_PREFIX = re .compile (r'label ta_r">\+(.*?)<' )
@@ -372,7 +374,7 @@ def too_many_rps_handler(self, error):
372374 return error .try_method ()
373375
374376 def auth_handler (self ):
375- raise AuthError (" No handler for two-factor authorization." )
377+ raise AuthError (' No handler for two-factor authentication' )
376378
377379 def get_api (self ):
378380 return VkApiMethod (self )
@@ -389,23 +391,17 @@ def method(self, method, values=None, captcha_sid=None, captcha_key=None, raw=Fa
389391 """
390392
391393 url = 'https://api.vk.com/method/%s' % method
392-
393- if values :
394- values = values .copy ()
395- else :
396- values = {}
394+ values = values .copy () if values else {}
397395
398396 if 'v' not in values :
399- values . update ({ 'v' : self .api_version })
397+ values [ 'v' ] = self .api_version
400398
401399 if self .token :
402- values . update ({ 'access_token' : self .token ['access_token' ]})
400+ values [ 'access_token' ] = self .token ['access_token' ]
403401
404402 if captcha_sid and captcha_key :
405- values .update ({
406- 'captcha_sid' : captcha_sid ,
407- 'captcha_key' : captcha_key
408- })
403+ values ['captcha_sid' ] = captcha_sid
404+ values ['captcha_key' ] = captcha_key
409405
410406 with self .lock :
411407 # Ограничение 3 запроса в секунду
0 commit comments