8585# gopher can return a socket.error
8686# check digest against correct (i.e. non-apache) implementation
8787
88- import string
8988import socket
9089import UserDict
9190import httplib
@@ -265,13 +264,13 @@ def add_handler(self, handler):
265264 self .handle_open [protocol ] = [handler ]
266265 added = 1
267266 continue
268- i = string .find (meth , '_' )
269- j = string . find ( meth [i + 1 :], '_' ) + i + 1
267+ i = meth .find ('_' )
268+ j = meth [i + 1 :]. find ( '_' ) + i + 1
270269 if j != - 1 and meth [i + 1 :j ] == 'error' :
271270 proto = meth [:i ]
272271 kind = meth [j + 1 :]
273272 try :
274- kind = string . atoi (kind )
273+ kind = int (kind )
275274 except ValueError :
276275 pass
277276 dict = self .handle_error .get (proto , {})
@@ -599,7 +598,7 @@ def http_error_401(self, req, fp, code, msg, headers):
599598 mo = HTTPBasicAuthHandler .rx .match (authreq )
600599 if mo :
601600 scheme , realm = mo .groups ()
602- if string .lower (scheme ) == 'basic' :
601+ if scheme .lower () == 'basic' :
603602 return self .retry_http_basic_auth (req , realm )
604603
605604 def retry_http_basic_auth (self , req , realm ):
@@ -613,7 +612,7 @@ def retry_http_basic_auth(self, req, realm):
613612 user ,pw = self .passwd .find_user_password (realm , host )
614613 if pw :
615614 raw = "%s:%s" % (user , pw )
616- auth = string . strip ( base64 .encodestring (raw ))
615+ auth = base64 .encodestring (raw ). strip ( )
617616 req .add_header ('Authorization' , 'Basic %s' % auth )
618617 resp = self .parent .open (req )
619618 self .__current_realm = None
@@ -638,12 +637,12 @@ def http_error_401(self, req, fp, code, msg, headers):
638637 # XXX could be mult. headers
639638 authreq = headers .get ('www-authenticate' , None )
640639 if authreq :
641- kind = string .split (authreq )[0 ]
640+ kind = authreq .split ()[0 ]
642641 if kind == 'Digest' :
643642 return self .retry_http_digest_auth (req , authreq )
644643
645644 def retry_http_digest_auth (self , req , auth ):
646- token , challenge = string .split (auth , ' ' , 1 )
645+ token , challenge = auth .split (' ' , 1 )
647646 chal = parse_keqv_list (parse_http_list (challenge ))
648647 auth = self .get_authorization (req , chal )
649648 if auth :
@@ -723,7 +722,7 @@ def encode_digest(digest):
723722 hexrep .append (hex (n )[- 1 ])
724723 n = ord (c ) & 0xf
725724 hexrep .append (hex (n )[- 1 ])
726- return string .join (hexrep , '' )
725+ return '' .join (hexrep )
727726
728727
729728class HTTPHandler (BaseHandler ):
@@ -772,7 +771,7 @@ def parse_keqv_list(l):
772771 """Parse list of key=value strings where keys are not duplicated."""
773772 parsed = {}
774773 for elt in l :
775- k , v = string .split (elt , '=' , 1 )
774+ k , v = elt .split ('=' , 1 )
776775 if v [0 ] == '"' and v [- 1 ] == '"' :
777776 v = v [1 :- 1 ]
778777 parsed [k ] = v
@@ -794,8 +793,8 @@ def parse_http_list(s):
794793 start = 0
795794 while i < end :
796795 cur = s [i :]
797- c = string .find (cur , ',' )
798- q = string .find (cur , '"' )
796+ c = cur .find (',' )
797+ q = cur .find ('"' )
799798 if c == - 1 :
800799 list .append (s [start :])
801800 break
@@ -822,7 +821,7 @@ def parse_http_list(s):
822821 else :
823822 inquote = 1
824823 i = i + q + 1
825- return map (string .strip , list )
824+ return map (lambda x : x .strip () , list )
826825
827826class FileHandler (BaseHandler ):
828827 # Use local file or FTP depending on form of URL
@@ -872,7 +871,7 @@ def ftp_open(self, req):
872871 port = ftplib .FTP_PORT
873872 path , attrs = splitattr (req .get_selector ())
874873 path = unquote (path )
875- dirs = string . splitfields ( path , '/' )
874+ dirs = path . split ( '/' )
876875 dirs , file = dirs [:- 1 ], dirs [- 1 ]
877876 if dirs and not dirs [0 ]:
878877 dirs = dirs [1 :]
@@ -882,9 +881,9 @@ def ftp_open(self, req):
882881 type = file and 'I' or 'D'
883882 for attr in attrs :
884883 attr , value = splitattr (attr )
885- if string .lower (attr ) == 'type' and \
884+ if attr .lower () == 'type' and \
886885 value in ('a' , 'A' , 'i' , 'I' , 'd' , 'D' ):
887- type = string .upper (value )
886+ type = value .upper ()
888887 fp , retrlen = fw .retrfile (file , type )
889888 if retrlen is not None and retrlen >= 0 :
890889 sf = StringIO ('Content-Length: %d\n ' % retrlen )
@@ -1048,7 +1047,7 @@ def at_cnri(req):
10481047 p = CustomProxy ('http' , at_cnri , 'proxy.cnri.reston.va.us' )
10491048 ph = CustomProxyHandler (p )
10501049
1051- install_opener (build_opener (dauth , bauth , cfh , GopherHandler , ph ))
1050+ # install_opener(build_opener(dauth, bauth, cfh, GopherHandler, ph))
10521051
10531052 for url in urls :
10541053 if type (url ) == types .TupleType :
0 commit comments