]> granicus.if.org Git - python/commitdiff
urllib.request - syntax changes enhancing readability. By Éric Araujo
authorSenthil Kumaran <senthil@uthcode.com>
Wed, 19 Oct 2011 18:50:13 +0000 (02:50 +0800)
committerSenthil Kumaran <senthil@uthcode.com>
Wed, 19 Oct 2011 18:50:13 +0000 (02:50 +0800)
1  2 
Lib/urllib/request.py

index 65ce287588ffb13b45eae848c607ae39925adbbe,8ea058fc6da61595d98476a56ed10a3231a43dd6..71011bda7100e1a2d0427ba0f80e3a6db4ca5b97
@@@ -830,20 -824,14 +829,20 @@@ class AbstractBasicAuthHandler
              self.retried += 1
  
          if authreq:
 -            mo = AbstractBasicAuthHandler.rx.search(authreq)
 -            if mo:
 -                scheme, quote, realm = mo.groups()
 -                if scheme.lower() == 'basic':
 -                    response = self.retry_http_basic_auth(host, req, realm)
 -                    if response and response.code != 401:
 -                        self.retried = 0
 -                    return response
 +            scheme = authreq.split()[0]
-             if not scheme.lower() == 'basic':
++            if scheme.lower() != 'basic':
 +                raise ValueError("AbstractBasicAuthHandler does not"
 +                                 " support the following scheme: '%s'" %
 +                                 scheme)
 +            else:
 +                mo = AbstractBasicAuthHandler.rx.search(authreq)
 +                if mo:
 +                    scheme, quote, realm = mo.groups()
 +                    if scheme.lower() == 'basic':
 +                        response = self.retry_http_basic_auth(host, req, realm)
 +                        if response and response.code != 401:
 +                            self.retried = 0
 +                        return response
  
      def retry_http_basic_auth(self, host, req, realm):
          user, pw = self.passwd.find_user_password(realm, host)
@@@ -929,9 -917,6 +928,9 @@@ class AbstractDigestAuthHandler
              scheme = authreq.split()[0]
              if scheme.lower() == 'digest':
                  return self.retry_http_digest_auth(req, authreq)
-             elif not scheme.lower() == 'basic':
++            elif scheme.lower() != 'basic':
 +                raise ValueError("AbstractDigestAuthHandler does not support"
 +                                 " the following scheme: '%s'" % scheme)
  
      def retry_http_digest_auth(self, req, auth):
          token, challenge = auth.split(' ', 1)