Kaydet (Commit) 66d9919c authored tarafından Eric S. Raymond's avatar Eric S. Raymond

String method conversion.

üst ee5e61d3
...@@ -216,7 +216,7 @@ class MH: ...@@ -216,7 +216,7 @@ class MH:
"""Create a new folder (or raise os.error if it cannot be created).""" """Create a new folder (or raise os.error if it cannot be created)."""
protect = pickline(self.profile, 'Folder-Protect') protect = pickline(self.profile, 'Folder-Protect')
if protect and isnumeric(protect): if protect and isnumeric(protect):
mode = string.atoi(protect, 8) mode = int(protect, 8)
else: else:
mode = FOLDER_PROTECT mode = FOLDER_PROTECT
os.mkdir(os.path.join(self.getpath(), name), mode) os.mkdir(os.path.join(self.getpath(), name), mode)
...@@ -286,7 +286,7 @@ class Folder: ...@@ -286,7 +286,7 @@ class Folder:
for name in os.listdir(self.getfullname()): for name in os.listdir(self.getfullname()):
if match(name): if match(name):
append(name) append(name)
messages = map(string.atoi, messages) messages = map(int, messages)
messages.sort() messages.sort()
if messages: if messages:
self.last = messages[-1] self.last = messages[-1]
...@@ -305,12 +305,12 @@ class Folder: ...@@ -305,12 +305,12 @@ class Folder:
while 1: while 1:
line = f.readline() line = f.readline()
if not line: break if not line: break
fields = string.splitfields(line, ':') fields = line.split(':')
if len(fields) != 2: if len(fields) != 2:
self.error('bad sequence in %s: %s' % self.error('bad sequence in %s: %s' %
(fullname, string.strip(line))) (fullname, line.strip()))
key = string.strip(fields[0]) key = fields[0].strip()
value = IntSet(string.strip(fields[1]), ' ').tolist() value = IntSet(fields[1].strip(), ' ').tolist()
sequences[key] = value sequences[key] = value
return sequences return sequences
...@@ -360,7 +360,7 @@ class Folder: ...@@ -360,7 +360,7 @@ class Folder:
if seq == 'all': if seq == 'all':
return all return all
# Test for X:Y before X-Y because 'seq:-n' matches both # Test for X:Y before X-Y because 'seq:-n' matches both
i = string.find(seq, ':') i = seq.find(':')
if i >= 0: if i >= 0:
head, dir, tail = seq[:i], '', seq[i+1:] head, dir, tail = seq[:i], '', seq[i+1:]
if tail[:1] in '-+': if tail[:1] in '-+':
...@@ -368,7 +368,7 @@ class Folder: ...@@ -368,7 +368,7 @@ class Folder:
if not isnumeric(tail): if not isnumeric(tail):
raise Error, "bad message list %s" % seq raise Error, "bad message list %s" % seq
try: try:
count = string.atoi(tail) count = int(tail)
except (ValueError, OverflowError): except (ValueError, OverflowError):
# Can't use sys.maxint because of i+count below # Can't use sys.maxint because of i+count below
count = len(all) count = len(all)
...@@ -398,7 +398,7 @@ class Folder: ...@@ -398,7 +398,7 @@ class Folder:
i = bisect(all, anchor-1) i = bisect(all, anchor-1)
return all[i:i+count] return all[i:i+count]
# Test for X-Y next # Test for X-Y next
i = string.find(seq, '-') i = seq.find('-')
if i >= 0: if i >= 0:
begin = self._parseindex(seq[:i], all) begin = self._parseindex(seq[:i], all)
end = self._parseindex(seq[i+1:], all) end = self._parseindex(seq[i+1:], all)
...@@ -431,7 +431,7 @@ class Folder: ...@@ -431,7 +431,7 @@ class Folder:
"""Internal: parse a message number (or cur, first, etc.).""" """Internal: parse a message number (or cur, first, etc.)."""
if isnumeric(seq): if isnumeric(seq):
try: try:
return string.atoi(seq) return int(seq)
except (OverflowError, ValueError): except (OverflowError, ValueError):
return sys.maxint return sys.maxint
if seq in ('cur', '.'): if seq in ('cur', '.'):
...@@ -681,16 +681,16 @@ class Message(mimetools.Message): ...@@ -681,16 +681,16 @@ class Message(mimetools.Message):
decide which headers to return (its argument is the header decide which headers to return (its argument is the header
name converted to lower case).""" name converted to lower case)."""
if not pred: if not pred:
return string.joinfields(self.headers, '') return ''.join(self.headers)
headers = [] headers = []
hit = 0 hit = 0
for line in self.headers: for line in self.headers:
if line[0] not in string.whitespace: if line[0] not in string.whitespace:
i = string.find(line, ':') i = line.find(':')
if i > 0: if i > 0:
hit = pred(string.lower(line[:i])) hit = pred(line[:i].lower())
if hit: headers.append(line) if hit: headers.append(line)
return string.joinfields(headers, '') return ''.joinfields(headers)
def getbodytext(self, decode = 1): def getbodytext(self, decode = 1):
"""Return the message's body text as string. This undoes a """Return the message's body text as string. This undoes a
...@@ -887,11 +887,11 @@ class IntSet: ...@@ -887,11 +887,11 @@ class IntSet:
def fromstring(self, data): def fromstring(self, data):
import string import string
new = [] new = []
for part in string.splitfields(data, self.sep): for part in data.split(self.sep):
list = [] list = []
for subp in string.splitfields(part, self.rng): for subp in part.split(self.rng):
s = string.strip(subp) s = subp.strip()
list.append(string.atoi(s)) list.append(int(s))
if len(list) == 1: if len(list) == 1:
new.append((list[0], list[0])) new.append((list[0], list[0]))
elif len(list) == 2 and list[0] <= list[1]: elif len(list) == 2 and list[0] <= list[1]:
...@@ -921,7 +921,7 @@ def pickline(file, key, casefold = 1): ...@@ -921,7 +921,7 @@ def pickline(file, key, casefold = 1):
if not line or line[0] not in string.whitespace: if not line or line[0] not in string.whitespace:
break break
text = text + line text = text + line
return string.strip(text) return text.strip()
return None return None
def updateline(file, key, value, casefold = 1): def updateline(file, key, value, casefold = 1):
...@@ -996,7 +996,7 @@ def test(): ...@@ -996,7 +996,7 @@ def test():
except Error, msg: except Error, msg:
print "Error:", msg print "Error:", msg
stuff = os.popen("pick %s 2>/dev/null" % `seq`).read() 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" print list, "<-- pick"
do('f.listmessages()') do('f.listmessages()')
......
...@@ -107,11 +107,10 @@ def intsplit(str, pat, maxsplit, retain): ...@@ -107,11 +107,10 @@ def intsplit(str, pat, maxsplit, retain):
# Capitalize words split using a pattern # Capitalize words split using a pattern
def capwords(str, pat='[^a-zA-Z0-9_]+'): def capwords(str, pat='[^a-zA-Z0-9_]+'):
import string
words = splitx(str, pat) words = splitx(str, pat)
for i in range(0, len(words), 2): for i in range(0, len(words), 2):
words[i] = string.capitalize(words[i]) words[i] = words[i].capitalize()
return string.joinfields(words, "") return "".joinfields(words)
# Internal subroutines: # Internal subroutines:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment