summaryrefslogtreecommitdiffstats
path: root/Lib/nntplib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-10-22 21:00:49 (GMT)
committerGuido van Rossum <guido@python.org>1997-10-22 21:00:49 (GMT)
commit9694fcab5332f27dc28b195ba1391e5491d2eaef (patch)
tree23dc3d9a7d1cc4b138ac2bffd028a519cba93b30 /Lib/nntplib.py
parent426916e50e1209d8ecc12678855dc531863a48c5 (diff)
downloadcpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.zip
cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.gz
cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.bz2
Convert all remaining *simple* cases of regex usage to re usage.
Diffstat (limited to 'Lib/nntplib.py')
-rw-r--r--Lib/nntplib.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index a266cbd..85c2a63 100644
--- a/Lib/nntplib.py
+++ b/Lib/nntplib.py
@@ -29,7 +29,7 @@
# Imports
-import regex
+import re
import socket
import string
@@ -313,13 +313,13 @@ class NNTP:
# - list: list of (nr, value) strings
def xhdr(self, hdr, str):
+ pat = re.compile('^([0-9]+) ?(.*)\n?')
resp, lines = self.longcmd('XHDR ' + hdr + ' ' + str)
for i in range(len(lines)):
line = lines[i]
- n = regex.match('^[0-9]+', line)
- nr = line[:n]
- if n < len(line) and line[n] == ' ': n = n+1
- lines[i] = (nr, line[n:])
+ m = pat.match(line)
+ if m:
+ lines[i] = m.group(1, 2)
return resp, lines
# Process an XOVER command (optional server extension) Arguments:
@@ -354,14 +354,13 @@ class NNTP:
# - list: list of (name,title) strings
def xgtitle(self, group):
- line_pat = regex.compile("^\([^ \t]+\)[ \t]+\(.*\)$")
+ line_pat = re.compile("^([^ \t]+)[ \t]+(.*)$")
resp, raw_lines = self.longcmd('XGTITLE ' + group)
lines = []
for raw_line in raw_lines:
- if line_pat.search(string.strip(raw_line)) == 0:
- lines.append(line_pat.group(1),
- line_pat.group(2))
-
+ match = line_pat.search(string.strip(raw_line))
+ if match:
+ lines.append(match.group(1, 2))
return resp, lines
# Process an XPATH command (optional server extension) Arguments: