summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/formatter.py8
-rw-r--r--Lib/nturl2path.py20
-rw-r--r--Lib/sre.py4
-rwxr-xr-xLib/token.py6
-rw-r--r--Lib/tokenize.py2
-rw-r--r--Lib/urllib2.py33
6 files changed, 35 insertions, 38 deletions
diff --git a/Lib/formatter.py b/Lib/formatter.py
index 359975b..8393e46 100644
--- a/Lib/formatter.py
+++ b/Lib/formatter.py
@@ -157,7 +157,7 @@ class AbstractFormatter:
label = s + label
index = index + 1
if case == 'I':
- return string.upper(label)
+ return label.upper()
return label
def add_flowing_data(self, data,
@@ -369,11 +369,11 @@ class DumbWriter(NullWriter):
def send_literal_data(self, data):
self.file.write(data)
- i = string.rfind(data, '\n')
+ i = data.rfind('\n')
if i >= 0:
self.col = 0
data = data[i+1:]
- data = string.expandtabs(data)
+ data = data.expandtabs()
self.col = self.col + len(data)
self.atbreak = 0
@@ -383,7 +383,7 @@ class DumbWriter(NullWriter):
col = self.col
maxcol = self.maxcol
write = self.file.write
- for word in string.split(data):
+ for word in data.split():
if atbreak:
if col + len(word) >= maxcol:
write('\n')
diff --git a/Lib/nturl2path.py b/Lib/nturl2path.py
index 7e78cb1..f7b0fbe 100644
--- a/Lib/nturl2path.py
+++ b/Lib/nturl2path.py
@@ -19,15 +19,15 @@ def url2pathname(url):
# convert this to \\host\path\on\remote\host
# (notice halving of slashes at the start of the path)
url = url[2:]
- components = string.split(url, '/')
+ components = url.split('/')
# make sure not to convert quoted slashes :-)
- return urllib.unquote(string.join(components, '\\'))
- comp = string.split(url, '|')
+ return urllib.unquote('\\'.join(components))
+ comp = url.split('|')
if len(comp) != 2 or comp[0][-1] not in string.letters:
error = 'Bad URL: ' + url
raise IOError, error
- drive = string.upper(comp[0][-1])
- components = string.split(comp[1], '/')
+ drive = comp[0][-1].upper()
+ components = comp[1].split('/')
path = drive + ':'
for comp in components:
if comp:
@@ -52,15 +52,15 @@ def pathname2url(p):
# convert this to ////host/path/on/remote/host
# (notice doubling of slashes at the start of the path)
p = '\\\\' + p
- components = string.split(p, '\\')
- return urllib.quote(string.join(components, '/'))
- comp = string.split(p, ':')
+ components = p.split('\\')
+ return urllib.quote('/'.join(components))
+ comp = p.split(':')
if len(comp) != 2 or len(comp[0]) > 1:
error = 'Bad path: ' + p
raise IOError, error
- drive = urllib.quote(string.upper(comp[0]))
- components = string.split(comp[1], '\\')
+ drive = urllib.quote(comp[0].upper())
+ components = comp[1].split('\\')
path = '///' + drive + '|'
for comp in components:
if comp:
diff --git a/Lib/sre.py b/Lib/sre.py
index 859ff9e..4533354 100644
--- a/Lib/sre.py
+++ b/Lib/sre.py
@@ -17,8 +17,6 @@
import sre_compile
import sre_parse
-import string
-
# flags
I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case
L = LOCALE = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale
@@ -109,7 +107,7 @@ _MAXCACHE = 100
def _join(seq, sep):
# internal: join into string having the same type as sep
- return string.join(seq, sep[:0])
+ return sep[:0].join(seq)
def _compile(*key):
# internal: compile pattern
diff --git a/Lib/token.py b/Lib/token.py
index 14f56d0..80dc032 100755
--- a/Lib/token.py
+++ b/Lib/token.py
@@ -94,7 +94,7 @@ def main():
except IOError, err:
sys.stdout.write("I/O error: %s\n" % str(err))
sys.exit(1)
- lines = string.splitfields(fp.read(), "\n")
+ lines = fp.read().split("\n")
fp.close()
prog = re.compile(
"#define[ \t][ \t]*([A-Z][A-Z_]*)[ \t][ \t]*([0-9][0-9]*)",
@@ -114,7 +114,7 @@ def main():
except IOError, err:
sys.stderr.write("I/O error: %s\n" % str(err))
sys.exit(2)
- format = string.splitfields(fp.read(), "\n")
+ format = fp.read().split("\n")
fp.close()
try:
start = format.index("#--start constants--") + 1
@@ -131,7 +131,7 @@ def main():
except IOError, err:
sys.stderr.write("I/O error: %s\n" % str(err))
sys.exit(4)
- fp.write(string.joinfields(format, "\n"))
+ fp.write("\n".join(format))
fp.close()
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index 3014b19..9f46612 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -26,7 +26,7 @@ tok_name[NL] = 'NL'
# Imagnumber is new. Expfloat is corrected to reject '0e4'.
# Note: to quote a backslash in a regex, it must be doubled in a r'aw' string.
-def group(*choices): return '(' + string.join(choices, '|') + ')'
+def group(*choices): return '(' + '|'.join(choices) + ')'
def any(*choices): return apply(group, choices) + '*'
def maybe(*choices): return apply(group, choices) + '?'
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index cf94d2f..a3ff482 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -85,7 +85,6 @@ f = urllib2.urlopen('http://www.python.org/')
# gopher can return a socket.error
# check digest against correct (i.e. non-apache) implementation
-import string
import socket
import UserDict
import httplib
@@ -265,13 +264,13 @@ class OpenerDirector:
self.handle_open[protocol] = [handler]
added = 1
continue
- i = string.find(meth, '_')
- j = string.find(meth[i+1:], '_') + i + 1
+ 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 = string.atoi(kind)
+ kind = int(kind)
except ValueError:
pass
dict = self.handle_error.get(proto, {})
@@ -599,7 +598,7 @@ class HTTPBasicAuthHandler(BaseHandler):
mo = HTTPBasicAuthHandler.rx.match(authreq)
if mo:
scheme, realm = mo.groups()
- if string.lower(scheme) == 'basic':
+ if scheme.lower() == 'basic':
return self.retry_http_basic_auth(req, realm)
def retry_http_basic_auth(self, req, realm):
@@ -613,7 +612,7 @@ class HTTPBasicAuthHandler(BaseHandler):
user,pw = self.passwd.find_user_password(realm, host)
if pw:
raw = "%s:%s" % (user, pw)
- auth = string.strip(base64.encodestring(raw))
+ auth = base64.encodestring(raw).strip()
req.add_header('Authorization', 'Basic %s' % auth)
resp = self.parent.open(req)
self.__current_realm = None
@@ -638,12 +637,12 @@ class HTTPDigestAuthHandler(BaseHandler):
# XXX could be mult. headers
authreq = headers.get('www-authenticate', None)
if authreq:
- kind = string.split(authreq)[0]
+ 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 = string.split(auth, ' ', 1)
+ token, challenge = auth.split(' ', 1)
chal = parse_keqv_list(parse_http_list(challenge))
auth = self.get_authorization(req, chal)
if auth:
@@ -723,7 +722,7 @@ def encode_digest(digest):
hexrep.append(hex(n)[-1])
n = ord(c) & 0xf
hexrep.append(hex(n)[-1])
- return string.join(hexrep, '')
+ return ''.join(hexrep)
class HTTPHandler(BaseHandler):
@@ -772,7 +771,7 @@ def parse_keqv_list(l):
"""Parse list of key=value strings where keys are not duplicated."""
parsed = {}
for elt in l:
- k, v = string.split(elt, '=', 1)
+ k, v = elt.split('=', 1)
if v[0] == '"' and v[-1] == '"':
v = v[1:-1]
parsed[k] = v
@@ -794,8 +793,8 @@ def parse_http_list(s):
start = 0
while i < end:
cur = s[i:]
- c = string.find(cur, ',')
- q = string.find(cur, '"')
+ c = cur.find(',')
+ q = cur.find('"')
if c == -1:
list.append(s[start:])
break
@@ -822,7 +821,7 @@ def parse_http_list(s):
else:
inquote = 1
i = i + q + 1
- return map(string.strip, list)
+ return map(lambda x: x.strip(), list)
class FileHandler(BaseHandler):
# Use local file or FTP depending on form of URL
@@ -872,7 +871,7 @@ class FTPHandler(BaseHandler):
port = ftplib.FTP_PORT
path, attrs = splitattr(req.get_selector())
path = unquote(path)
- dirs = string.splitfields(path, '/')
+ dirs = path.split('/')
dirs, file = dirs[:-1], dirs[-1]
if dirs and not dirs[0]:
dirs = dirs[1:]
@@ -882,9 +881,9 @@ class FTPHandler(BaseHandler):
type = file and 'I' or 'D'
for attr in attrs:
attr, value = splitattr(attr)
- if string.lower(attr) == 'type' and \
+ if attr.lower() == 'type' and \
value in ('a', 'A', 'i', 'I', 'd', 'D'):
- type = string.upper(value)
+ type = value.upper()
fp, retrlen = fw.retrfile(file, type)
if retrlen is not None and retrlen >= 0:
sf = StringIO('Content-Length: %d\n' % retrlen)
@@ -1048,7 +1047,7 @@ if __name__ == "__main__":
p = CustomProxy('http', at_cnri, 'proxy.cnri.reston.va.us')
ph = CustomProxyHandler(p)
- install_opener(build_opener(dauth, bauth, cfh, GopherHandler, ph))
+ #install_opener(build_opener(dauth, bauth, cfh, GopherHandler, ph))
for url in urls:
if type(url) == types.TupleType: