summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2001-02-09 09:19:27 (GMT)
committerEric S. Raymond <esr@thyrsus.com>2001-02-09 09:19:27 (GMT)
commit66d9919cab903e152d206b7edb853799eca564d0 (patch)
tree02904c744034f367e8be10dc15c8ea7007d8f1d4 /Lib
parentee5e61d3bc127c9d3c6ac752b2d381718da910ef (diff)
downloadcpython-66d9919cab903e152d206b7edb853799eca564d0.zip
cpython-66d9919cab903e152d206b7edb853799eca564d0.tar.gz
cpython-66d9919cab903e152d206b7edb853799eca564d0.tar.bz2
String method conversion.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/mhlib.py40
-rw-r--r--Lib/regsub.py5
2 files changed, 22 insertions, 23 deletions
diff --git a/Lib/mhlib.py b/Lib/mhlib.py
index dbfa9e1..7dbe875 100644
--- a/Lib/mhlib.py
+++ b/Lib/mhlib.py
@@ -216,7 +216,7 @@ class MH:
"""Create a new folder (or raise os.error if it cannot be created)."""
protect = pickline(self.profile, 'Folder-Protect')
if protect and isnumeric(protect):
- mode = string.atoi(protect, 8)
+ mode = int(protect, 8)
else:
mode = FOLDER_PROTECT
os.mkdir(os.path.join(self.getpath(), name), mode)
@@ -286,7 +286,7 @@ class Folder:
for name in os.listdir(self.getfullname()):
if match(name):
append(name)
- messages = map(string.atoi, messages)
+ messages = map(int, messages)
messages.sort()
if messages:
self.last = messages[-1]
@@ -305,12 +305,12 @@ class Folder:
while 1:
line = f.readline()
if not line: break
- fields = string.splitfields(line, ':')
+ fields = line.split(':')
if len(fields) != 2:
self.error('bad sequence in %s: %s' %
- (fullname, string.strip(line)))
- key = string.strip(fields[0])
- value = IntSet(string.strip(fields[1]), ' ').tolist()
+ (fullname, line.strip()))
+ key = fields[0].strip()
+ value = IntSet(fields[1].strip(), ' ').tolist()
sequences[key] = value
return sequences
@@ -360,7 +360,7 @@ class Folder:
if seq == 'all':
return all
# Test for X:Y before X-Y because 'seq:-n' matches both
- i = string.find(seq, ':')
+ i = seq.find(':')
if i >= 0:
head, dir, tail = seq[:i], '', seq[i+1:]
if tail[:1] in '-+':
@@ -368,7 +368,7 @@ class Folder:
if not isnumeric(tail):
raise Error, "bad message list %s" % seq
try:
- count = string.atoi(tail)
+ count = int(tail)
except (ValueError, OverflowError):
# Can't use sys.maxint because of i+count below
count = len(all)
@@ -398,7 +398,7 @@ class Folder:
i = bisect(all, anchor-1)
return all[i:i+count]
# Test for X-Y next
- i = string.find(seq, '-')
+ i = seq.find('-')
if i >= 0:
begin = self._parseindex(seq[:i], all)
end = self._parseindex(seq[i+1:], all)
@@ -431,7 +431,7 @@ class Folder:
"""Internal: parse a message number (or cur, first, etc.)."""
if isnumeric(seq):
try:
- return string.atoi(seq)
+ return int(seq)
except (OverflowError, ValueError):
return sys.maxint
if seq in ('cur', '.'):
@@ -681,16 +681,16 @@ class Message(mimetools.Message):
decide which headers to return (its argument is the header
name converted to lower case)."""
if not pred:
- return string.joinfields(self.headers, '')
+ return ''.join(self.headers)
headers = []
hit = 0
for line in self.headers:
if line[0] not in string.whitespace:
- i = string.find(line, ':')
+ i = line.find(':')
if i > 0:
- hit = pred(string.lower(line[:i]))
+ hit = pred(line[:i].lower())
if hit: headers.append(line)
- return string.joinfields(headers, '')
+ return ''.joinfields(headers)
def getbodytext(self, decode = 1):
"""Return the message's body text as string. This undoes a
@@ -887,11 +887,11 @@ class IntSet:
def fromstring(self, data):
import string
new = []
- for part in string.splitfields(data, self.sep):
+ for part in data.split(self.sep):
list = []
- for subp in string.splitfields(part, self.rng):
- s = string.strip(subp)
- list.append(string.atoi(s))
+ for subp in part.split(self.rng):
+ s = subp.strip()
+ list.append(int(s))
if len(list) == 1:
new.append((list[0], list[0]))
elif len(list) == 2 and list[0] <= list[1]:
@@ -921,7 +921,7 @@ def pickline(file, key, casefold = 1):
if not line or line[0] not in string.whitespace:
break
text = text + line
- return string.strip(text)
+ return text.strip()
return None
def updateline(file, key, value, casefold = 1):
@@ -996,7 +996,7 @@ def test():
except Error, msg:
print "Error:", msg
stuff = os.popen("pick %s 2>/dev/null" % `seq`).read()
- list = map(string.atoi, string.split(stuff))
+ list = map(int, stuff.split())
print list, "<-- pick"
do('f.listmessages()')
diff --git a/Lib/regsub.py b/Lib/regsub.py
index 4a36512..7778602 100644
--- a/Lib/regsub.py
+++ b/Lib/regsub.py
@@ -107,11 +107,10 @@ def intsplit(str, pat, maxsplit, retain):
# Capitalize words split using a pattern
def capwords(str, pat='[^a-zA-Z0-9_]+'):
- import string
words = splitx(str, pat)
for i in range(0, len(words), 2):
- words[i] = string.capitalize(words[i])
- return string.joinfields(words, "")
+ words[i] = words[i].capitalize()
+ return "".joinfields(words)
# Internal subroutines: