diff options
author | Guido van Rossum <guido@python.org> | 1997-10-22 20:49:52 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-10-22 20:49:52 (GMT) |
commit | acfb82a530c2fde7f708b93aac6a35504c207093 (patch) | |
tree | 4d0372f62d5689e0c9ad0aea7d9bf0c49ff9d2af /Lib | |
parent | 8566e474b4e54956a14f056173692c834f40f1a5 (diff) | |
download | cpython-acfb82a530c2fde7f708b93aac6a35504c207093.zip cpython-acfb82a530c2fde7f708b93aac6a35504c207093.tar.gz cpython-acfb82a530c2fde7f708b93aac6a35504c207093.tar.bz2 |
Use re instead of regex. Also remove bogus return statement from __init__().
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/ftplib.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py index 0ebefa8..ec7d479 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -105,7 +105,6 @@ class FTP: if host: resp = self.connect(host) if user: resp = self.login(user, passwd, acct) - return resp def connect(self, host = '', port = 0): '''Connect to host. Arguments are: @@ -469,8 +468,7 @@ class FTP: del self.file, self.sock -import regex -_150_re = regex.compile("150 .* (\([0-9][0-9]*\) bytes)", regex.casefold) +_150_re = None def parse150(resp): '''Parse the '150' response for a RETR request. @@ -479,9 +477,13 @@ def parse150(resp): ''' if resp[:3] != '150': raise error_reply, resp - length = _150_re.match(resp) - if length >= 0: - return string.atoi(_150_re.group(1)) + global _150_re + if _150_re is None: + import re + _150_re = re.compile("150 .* \(([0-9][0-9]*) bytes\)", re.IGNORECASE) + m = _150_re.match(resp) + if m: + return string.atoi(m.group(1)) return None |