[Python-checkins] CVS: python/dist/src/Lib urllib2.py,1.7,1.8

Eric S. Raymond esr@users.sourceforge.net
Fri, 09 Feb 2001 02:55:22 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv10941

Modified Files:
	urllib2.py 
Log Message:
String method conversion.


Index: urllib2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/urllib2.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** urllib2.py	2001/01/15 03:34:38	1.7
--- urllib2.py	2001/02/09 10:55:20	1.8
***************
*** 86,90 ****
  # check digest against correct (i.e. non-apache) implementation
  
- import string
  import socket
  import UserDict
--- 86,89 ----
***************
*** 266,276 ****
                  added = 1
                  continue
!             i = string.find(meth, '_')
!             j = string.find(meth[i+1:], '_') + i + 1
              if j != -1 and meth[i+1:j] == 'error':
                  proto = meth[:i]
                  kind = meth[j+1:]
                  try:
!                     kind = string.atoi(kind)
                  except ValueError:
                      pass
--- 265,275 ----
                  added = 1
                  continue
!             i = meth.find('_')
!             j = meth[i+1:].find('_') + i + 1
              if j != -1 and meth[i+1:j] == 'error':
                  proto = meth[:i]
                  kind = meth[j+1:]
                  try:
!                     kind = int(kind)
                  except ValueError:
                      pass
***************
*** 600,604 ****
              if mo:
                  scheme, realm = mo.groups()
!                 if string.lower(scheme) == 'basic':
                      return self.retry_http_basic_auth(req, realm)
  
--- 599,603 ----
              if mo:
                  scheme, realm = mo.groups()
!                 if scheme.lower() == 'basic':
                      return self.retry_http_basic_auth(req, realm)
  
***************
*** 614,618 ****
          if pw:
              raw = "%s:%s" % (user, pw)
!             auth = string.strip(base64.encodestring(raw))
              req.add_header('Authorization', 'Basic %s' % auth)
              resp = self.parent.open(req)
--- 613,617 ----
          if pw:
              raw = "%s:%s" % (user, pw)
!             auth = base64.encodestring(raw).strip()
              req.add_header('Authorization', 'Basic %s' % auth)
              resp = self.parent.open(req)
***************
*** 639,648 ****
          authreq = headers.get('www-authenticate', None)
          if authreq:
!             kind = string.split(authreq)[0]
              if kind == 'Digest':
                  return self.retry_http_digest_auth(req, authreq)
  
      def retry_http_digest_auth(self, req, auth):
!         token, challenge = string.split(auth, ' ', 1)
          chal = parse_keqv_list(parse_http_list(challenge))
          auth = self.get_authorization(req, chal)
--- 638,647 ----
          authreq = headers.get('www-authenticate', None)
          if authreq:
!             kind = authreq.split()[0]
              if kind == 'Digest':
                  return self.retry_http_digest_auth(req, authreq)
  
      def retry_http_digest_auth(self, req, auth):
!         token, challenge = auth.split(' ', 1)
          chal = parse_keqv_list(parse_http_list(challenge))
          auth = self.get_authorization(req, chal)
***************
*** 724,728 ****
          n = ord(c) & 0xf
          hexrep.append(hex(n)[-1])
!     return string.join(hexrep, '')
  
  
--- 723,727 ----
          n = ord(c) & 0xf
          hexrep.append(hex(n)[-1])
!     return ''.join(hexrep)
  
  
***************
*** 773,777 ****
      parsed = {}
      for elt in l:
!         k, v = string.split(elt, '=', 1)
          if v[0] == '"' and v[-1] == '"':
              v = v[1:-1]
--- 772,776 ----
      parsed = {}
      for elt in l:
!         k, v = elt.split('=', 1)
          if v[0] == '"' and v[-1] == '"':
              v = v[1:-1]
***************
*** 795,800 ****
      while i < end:
          cur = s[i:]
!         c = string.find(cur, ',')
!         q = string.find(cur, '"')
          if c == -1:
              list.append(s[start:])
--- 794,799 ----
      while i < end:
          cur = s[i:]
!         c = cur.find(',')
!         q = cur.find('"')
          if c == -1:
              list.append(s[start:])
***************
*** 823,827 ****
                  inquote = 1
                  i = i + q + 1
!     return map(string.strip, list)
  
  class FileHandler(BaseHandler):
--- 822,826 ----
                  inquote = 1
                  i = i + q + 1
!     return map(lambda x: x.strip(), list)
  
  class FileHandler(BaseHandler):
***************
*** 873,877 ****
          path, attrs = splitattr(req.get_selector())
          path = unquote(path)
!         dirs = string.splitfields(path, '/')
          dirs, file = dirs[:-1], dirs[-1]
          if dirs and not dirs[0]:
--- 872,876 ----
          path, attrs = splitattr(req.get_selector())
          path = unquote(path)
!         dirs = path.split('/')
          dirs, file = dirs[:-1], dirs[-1]
          if dirs and not dirs[0]:
***************
*** 883,889 ****
              for attr in attrs:
                  attr, value = splitattr(attr)
!                 if string.lower(attr) == 'type' and \
                     value in ('a', 'A', 'i', 'I', 'd', 'D'):
!                     type = string.upper(value)
              fp, retrlen = fw.retrfile(file, type)
              if retrlen is not None and retrlen >= 0:
--- 882,888 ----
              for attr in attrs:
                  attr, value = splitattr(attr)
!                 if attr.lower() == 'type' and \
                     value in ('a', 'A', 'i', 'I', 'd', 'D'):
!                     type = value.upper()
              fp, retrlen = fw.retrfile(file, type)
              if retrlen is not None and retrlen >= 0:
***************
*** 1049,1053 ****
      ph = CustomProxyHandler(p)
  
!     install_opener(build_opener(dauth, bauth, cfh, GopherHandler, ph))
  
      for url in urls:
--- 1048,1052 ----
      ph = CustomProxyHandler(p)
  
!     #install_opener(build_opener(dauth, bauth, cfh, GopherHandler, ph))
  
      for url in urls: