mirror of https://github.com/python/cpython
Get rid of string functions.
This commit is contained in:
parent
c80f182dc4
commit
e6e03eafed
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import rfc822
|
import rfc822
|
||||||
import string
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,17 +24,17 @@ class Message(rfc822.Message):
|
||||||
if str is None:
|
if str is None:
|
||||||
str = 'text/plain'
|
str = 'text/plain'
|
||||||
if ';' in str:
|
if ';' in str:
|
||||||
i = string.index(str, ';')
|
i = str.index(';')
|
||||||
self.plisttext = str[i:]
|
self.plisttext = str[i:]
|
||||||
str = str[:i]
|
str = str[:i]
|
||||||
else:
|
else:
|
||||||
self.plisttext = ''
|
self.plisttext = ''
|
||||||
fields = string.splitfields(str, '/')
|
fields = str.split('/')
|
||||||
for i in range(len(fields)):
|
for i in range(len(fields)):
|
||||||
fields[i] = string.lower(string.strip(fields[i]))
|
fields[i] = fields[i].strip().lower()
|
||||||
self.type = string.joinfields(fields, '/')
|
self.type = '/'.join(fields)
|
||||||
self.maintype = fields[0]
|
self.maintype = fields[0]
|
||||||
self.subtype = string.joinfields(fields[1:], '/')
|
self.subtype = '/'.join(fields[1:])
|
||||||
|
|
||||||
def parseplist(self):
|
def parseplist(self):
|
||||||
str = self.plisttext
|
str = self.plisttext
|
||||||
|
@ -44,22 +43,22 @@ class Message(rfc822.Message):
|
||||||
str = str[1:]
|
str = str[1:]
|
||||||
if ';' in str:
|
if ';' in str:
|
||||||
# XXX Should parse quotes!
|
# XXX Should parse quotes!
|
||||||
end = string.index(str, ';')
|
end = str.index(';')
|
||||||
else:
|
else:
|
||||||
end = len(str)
|
end = len(str)
|
||||||
f = str[:end]
|
f = str[:end]
|
||||||
if '=' in f:
|
if '=' in f:
|
||||||
i = string.index(f, '=')
|
i = f.index('=')
|
||||||
f = string.lower(string.strip(f[:i])) + \
|
f = f[:i].strip().lower() + \
|
||||||
'=' + string.strip(f[i+1:])
|
'=' + f[i+1:].strip()
|
||||||
self.plist.append(string.strip(f))
|
self.plist.append(f.strip())
|
||||||
str = str[end:]
|
str = str[end:]
|
||||||
|
|
||||||
def getplist(self):
|
def getplist(self):
|
||||||
return self.plist
|
return self.plist
|
||||||
|
|
||||||
def getparam(self, name):
|
def getparam(self, name):
|
||||||
name = string.lower(name) + '='
|
name = name.lower() + '='
|
||||||
n = len(name)
|
n = len(name)
|
||||||
for p in self.plist:
|
for p in self.plist:
|
||||||
if p[:n] == name:
|
if p[:n] == name:
|
||||||
|
@ -69,15 +68,15 @@ class Message(rfc822.Message):
|
||||||
def getparamnames(self):
|
def getparamnames(self):
|
||||||
result = []
|
result = []
|
||||||
for p in self.plist:
|
for p in self.plist:
|
||||||
i = string.find(p, '=')
|
i = p.find('=')
|
||||||
if i >= 0:
|
if i >= 0:
|
||||||
result.append(string.lower(p[:i]))
|
result.append(p[:i].lower())
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getencoding(self):
|
def getencoding(self):
|
||||||
if self.encodingheader is None:
|
if self.encodingheader is None:
|
||||||
return '7bit'
|
return '7bit'
|
||||||
return string.lower(self.encodingheader)
|
return self.encodingheader.lower()
|
||||||
|
|
||||||
def gettype(self):
|
def gettype(self):
|
||||||
return self.type
|
return self.type
|
||||||
|
|
Loading…
Reference in New Issue