mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
String method conversion.
This commit is contained in:
parent
341f929f51
commit
b9c24fb543
1 changed files with 9 additions and 10 deletions
|
@ -31,7 +31,6 @@ are strings, not numbers, since they are rarely used for calculations.
|
||||||
# Imports
|
# Imports
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import string
|
|
||||||
|
|
||||||
__all__ = ["NNTP","NNTPReplyError","NNTPTemporaryError",
|
__all__ = ["NNTP","NNTPReplyError","NNTPTemporaryError",
|
||||||
"NNTPPermanentError","NNTPProtocolError","NNTPDataError",
|
"NNTPPermanentError","NNTPProtocolError","NNTPDataError",
|
||||||
|
@ -267,7 +266,7 @@ class NNTP:
|
||||||
resp, list = self.longcmd('LIST')
|
resp, list = self.longcmd('LIST')
|
||||||
for i in range(len(list)):
|
for i in range(len(list)):
|
||||||
# Parse lines into "group last first flag"
|
# Parse lines into "group last first flag"
|
||||||
list[i] = tuple(string.split(list[i]))
|
list[i] = tuple(list[i].split())
|
||||||
return resp, list
|
return resp, list
|
||||||
|
|
||||||
def group(self, name):
|
def group(self, name):
|
||||||
|
@ -283,7 +282,7 @@ class NNTP:
|
||||||
resp = self.shortcmd('GROUP ' + name)
|
resp = self.shortcmd('GROUP ' + name)
|
||||||
if resp[:3] != '211':
|
if resp[:3] != '211':
|
||||||
raise NNTPReplyError(resp)
|
raise NNTPReplyError(resp)
|
||||||
words = string.split(resp)
|
words = resp.split()
|
||||||
count = first = last = 0
|
count = first = last = 0
|
||||||
n = len(words)
|
n = len(words)
|
||||||
if n > 1:
|
if n > 1:
|
||||||
|
@ -293,7 +292,7 @@ class NNTP:
|
||||||
if n > 3:
|
if n > 3:
|
||||||
last = words[3]
|
last = words[3]
|
||||||
if n > 4:
|
if n > 4:
|
||||||
name = string.lower(words[4])
|
name = words[4].lower()
|
||||||
return resp, count, first, last, name
|
return resp, count, first, last, name
|
||||||
|
|
||||||
def help(self):
|
def help(self):
|
||||||
|
@ -307,7 +306,7 @@ class NNTP:
|
||||||
"""Internal: parse the response of a STAT, NEXT or LAST command."""
|
"""Internal: parse the response of a STAT, NEXT or LAST command."""
|
||||||
if resp[:2] != '22':
|
if resp[:2] != '22':
|
||||||
raise NNTPReplyError(resp)
|
raise NNTPReplyError(resp)
|
||||||
words = string.split(resp)
|
words = resp.split()
|
||||||
nr = 0
|
nr = 0
|
||||||
id = ''
|
id = ''
|
||||||
n = len(words)
|
n = len(words)
|
||||||
|
@ -414,14 +413,14 @@ class NNTP:
|
||||||
resp, lines = self.longcmd('XOVER ' + start + '-' + end)
|
resp, lines = self.longcmd('XOVER ' + start + '-' + end)
|
||||||
xover_lines = []
|
xover_lines = []
|
||||||
for line in lines:
|
for line in lines:
|
||||||
elem = string.splitfields(line,"\t")
|
elem = line.split("\t")
|
||||||
try:
|
try:
|
||||||
xover_lines.append((elem[0],
|
xover_lines.append((elem[0],
|
||||||
elem[1],
|
elem[1],
|
||||||
elem[2],
|
elem[2],
|
||||||
elem[3],
|
elem[3],
|
||||||
elem[4],
|
elem[4],
|
||||||
string.split(elem[5]),
|
elem[5].split(),
|
||||||
elem[6],
|
elem[6],
|
||||||
elem[7]))
|
elem[7]))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
@ -439,7 +438,7 @@ class NNTP:
|
||||||
resp, raw_lines = self.longcmd('XGTITLE ' + group)
|
resp, raw_lines = self.longcmd('XGTITLE ' + group)
|
||||||
lines = []
|
lines = []
|
||||||
for raw_line in raw_lines:
|
for raw_line in raw_lines:
|
||||||
match = line_pat.search(string.strip(raw_line))
|
match = line_pat.search(raw_line.strip())
|
||||||
if match:
|
if match:
|
||||||
lines.append(match.group(1, 2))
|
lines.append(match.group(1, 2))
|
||||||
return resp, lines
|
return resp, lines
|
||||||
|
@ -455,7 +454,7 @@ class NNTP:
|
||||||
if resp[:3] != '223':
|
if resp[:3] != '223':
|
||||||
raise NNTPReplyError(resp)
|
raise NNTPReplyError(resp)
|
||||||
try:
|
try:
|
||||||
[resp_num, path] = string.split(resp)
|
[resp_num, path] = resp.split()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise NNTPReplyError(resp)
|
raise NNTPReplyError(resp)
|
||||||
else:
|
else:
|
||||||
|
@ -472,7 +471,7 @@ class NNTP:
|
||||||
resp = self.shortcmd("DATE")
|
resp = self.shortcmd("DATE")
|
||||||
if resp[:3] != '111':
|
if resp[:3] != '111':
|
||||||
raise NNTPReplyError(resp)
|
raise NNTPReplyError(resp)
|
||||||
elem = string.split(resp)
|
elem = resp.split()
|
||||||
if len(elem) != 2:
|
if len(elem) != 2:
|
||||||
raise NNTPDataError(resp)
|
raise NNTPDataError(resp)
|
||||||
date = elem[1][2:8]
|
date = elem[1][2:8]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue