Kaydet (Commit) 6b8c5283 authored tarafından Eric S. Raymond's avatar Eric S. Raymond

String method conversion.

üst 909bc1cf
...@@ -27,7 +27,7 @@ CHARSET = 'ISO-8859-1' # default charset for non-US-ASCII mail ...@@ -27,7 +27,7 @@ CHARSET = 'ISO-8859-1' # default charset for non-US-ASCII mail
QUOTE = '> ' # string replies are quoted with QUOTE = '> ' # string replies are quoted with
# End configure # End configure
import re, string import re
__all__ = ["mimify","unmimify","mime_encode_header","mime_decode_header"] __all__ = ["mimify","unmimify","mime_encode_header","mime_decode_header"]
...@@ -96,7 +96,7 @@ def mime_decode(line): ...@@ -96,7 +96,7 @@ def mime_decode(line):
if res is None: if res is None:
break break
newline = newline + line[pos:res.start(0)] + \ newline = newline + line[pos:res.start(0)] + \
chr(string.atoi(res.group(1), 16)) chr(int(res.group(1), 16))
pos = res.end(0) pos = res.end(0)
return newline + line[pos:] return newline + line[pos:]
...@@ -110,7 +110,7 @@ def mime_decode_header(line): ...@@ -110,7 +110,7 @@ def mime_decode_header(line):
break break
match = res.group(1) match = res.group(1)
# convert underscores to spaces (before =XX conversion!) # convert underscores to spaces (before =XX conversion!)
match = string.join(string.split(match, '_'), ' ') match = ' '.join(string.split(match, '_'))
newline = newline + line[pos:res.start(0)] + mime_decode(match) newline = newline + line[pos:res.start(0)] + mime_decode(match)
pos = res.end(0) pos = res.end(0)
return newline + line[pos:] return newline + line[pos:]
...@@ -232,14 +232,14 @@ def mime_encode(line, header): ...@@ -232,14 +232,14 @@ def mime_encode(line, header):
pos = 0 pos = 0
if len(line) >= 5 and line[:5] == 'From ': if len(line) >= 5 and line[:5] == 'From ':
# quote 'From ' at the start of a line for stupid mailers # quote 'From ' at the start of a line for stupid mailers
newline = string.upper('=%02x' % ord('F')) newline = ('=%02x' % ord('F')).upper()
pos = 1 pos = 1
while 1: while 1:
res = reg.search(line, pos) res = reg.search(line, pos)
if res is None: if res is None:
break break
newline = newline + line[pos:res.start(0)] + \ newline = newline + line[pos:res.start(0)] + \
string.upper('=%02x' % ord(res.group(0))) ('=%02x' % ord(res.group(0))).upper()
pos = res.end(0) pos = res.end(0)
line = newline + line[pos:] line = newline + line[pos:]
...@@ -346,7 +346,7 @@ def mimify_part(ifile, ofile, is_mime): ...@@ -346,7 +346,7 @@ def mimify_part(ifile, ofile, is_mime):
if chrset_res: if chrset_res:
if has_iso_chars: if has_iso_chars:
# change us-ascii into iso-8859-1 # change us-ascii into iso-8859-1
if string.lower(chrset_res.group(2)) == 'us-ascii': if chrset_res.group(2).lower() == 'us-ascii':
line = '%s%s%s' % (chrset_res.group(1), line = '%s%s%s' % (chrset_res.group(1),
CHARSET, CHARSET,
chrset_res.group(3)) chrset_res.group(3))
...@@ -447,7 +447,7 @@ if __name__ == '__main__' or (len(sys.argv) > 0 and sys.argv[0] == 'mimify'): ...@@ -447,7 +447,7 @@ if __name__ == '__main__' or (len(sys.argv) > 0 and sys.argv[0] == 'mimify'):
encode = unmimify encode = unmimify
elif o == '-l': elif o == '-l':
try: try:
MAXLEN = string.atoi(a) MAXLEN = int(a)
except: except:
print usage print usage
sys.exit(1) sys.exit(1)
......
...@@ -40,7 +40,6 @@ To do: ...@@ -40,7 +40,6 @@ To do:
import sys import sys
import socket import socket
import select import select
import string
# Tunable parameters # Tunable parameters
DEBUGLEVEL = 0 DEBUGLEVEL = 0
...@@ -187,7 +186,7 @@ class Telnet: ...@@ -187,7 +186,7 @@ class Telnet:
""" """
if IAC in buffer: if IAC in buffer:
buffer = string.replace(buffer, IAC, IAC+IAC) buffer = buffer.replace(IAC, IAC+IAC)
self.msg("send %s", `buffer`) self.msg("send %s", `buffer`)
self.sock.send(buffer) self.sock.send(buffer)
...@@ -201,7 +200,7 @@ class Telnet: ...@@ -201,7 +200,7 @@ class Telnet:
""" """
n = len(match) n = len(match)
self.process_rawq() self.process_rawq()
i = string.find(self.cookedq, match) i = self.cookedq.find(match)
if i >= 0: if i >= 0:
i = i+n i = i+n
buf = self.cookedq[:i] buf = self.cookedq[:i]
...@@ -215,7 +214,7 @@ class Telnet: ...@@ -215,7 +214,7 @@ class Telnet:
i = max(0, len(self.cookedq)-n) i = max(0, len(self.cookedq)-n)
self.fill_rawq() self.fill_rawq()
self.process_rawq() self.process_rawq()
i = string.find(self.cookedq, match, i) i = self.cookedq.find(match, i)
if i >= 0: if i >= 0:
i = i+n i = i+n
buf = self.cookedq[:i] buf = self.cookedq[:i]
......
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