From e226131e596aa6bd55c72969b507823c85b5c06c Mon Sep 17 00:00:00 2001 From: calvin Date: Mon, 24 Jan 2005 19:31:13 +0000 Subject: [PATCH] use new nntp argument usenetrc git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2207 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- TODO | 4 --- linkcheck/checker/nntpurl.py | 69 +----------------------------------- 2 files changed, 1 insertion(+), 72 deletions(-) diff --git a/TODO b/TODO index a3fd3ce0..4a053e34 100644 --- a/TODO +++ b/TODO @@ -11,10 +11,6 @@ Possible improvements people could work on: - [BUGFIX] when an URL is found in the cache and it has a broken anchor, the broken anchor name is not displayed as a warning -- [OPTIMIZATION] Python 2.4 introduced an "usenetrc" option to ignore - ~/.netrc for NNTP. Thus we could get rid of our custom NNTP class that - ignores ~/.netrc completely and use "usenetrc=False" instead. - - [USAGE] make a nice GUI for linkchecker - [OPTIMIZATION] SF bug #992389 bit me when I wanted to do absolute imports diff --git a/linkcheck/checker/nntpurl.py b/linkcheck/checker/nntpurl.py index b965a418..d113f9b7 100644 --- a/linkcheck/checker/nntpurl.py +++ b/linkcheck/checker/nntpurl.py @@ -32,73 +32,6 @@ import linkcheck.log random.seed() -class NoNetrcNNTP (nntplib.NNTP): - """ - NNTP class ignoring possible entries in ~/.netrc. - """ - - def __init__ (self, host, port=nntplib.NNTP_PORT, user=None, - password=None, readermode=None): - """ - Initialize an instance. Arguments: - - host: hostname to connect to - - port: port to connect to (default the standard NNTP port) - - user: username to authenticate with - - password: password to use with username - - readermode: if true, send 'mode reader' command after - connecting. - - readermode is sometimes necessary if you are connecting to an - NNTP server on the local machine and intend to call - reader-specific comamnds, such as `group'. If you get - unexpected NNTPPermanentErrors, you might need to set - readermode. - """ - self.host = host - self.port = port - self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.sock.connect((self.host, self.port)) - self.file = self.sock.makefile('rb') - self.debugging = 0 - self.welcome = self.getresp() - - # 'mode reader' is sometimes necessary to enable 'reader' mode. - # However, the order in which 'mode reader' and 'authinfo' need to - # arrive differs between some NNTP servers. Try to send - # 'mode reader', and if it fails with an authorization failed - # error, try again after sending authinfo. - readermode_afterauth = 0 - if readermode: - try: - self.welcome = self.shortcmd('mode reader') - except nntplib.NNTPPermanentError: - # error 500, probably 'not implemented' - pass - except nntplib.NNTPTemporaryError, e: - if user and e.response[:3] == '480': - # Need authorization before 'mode reader' - readermode_afterauth = 1 - else: - raise - # Perform NNRP authentication if needed. - if user: - resp = self.shortcmd('authinfo user '+user) - if resp[:3] == '381': - if not password: - raise nntplib.NNTPReplyError(resp) - else: - resp = self.shortcmd( - 'authinfo pass '+password) - if resp[:3] != '281': - raise nntplib.NNTPPermanentError(resp) - if readermode_afterauth: - try: - self.welcome = self.shortcmd('mode reader') - except nntplib.NNTPPermanentError: - # error 500, probably 'not implemented' - pass - - class NntpUrl (urlbase.UrlBase): """ Url link with NNTP scheme. @@ -141,7 +74,7 @@ class NntpUrl (urlbase.UrlBase): while tries < 5: tries += 1 try: - nntp = NoNetrcNNTP(nntpserver) + nntp = NNTP(nntpserver, usenetrc=False) except nntplib.error_perm: value = sys.exc_info()[1] if re.compile("^50[45]").search(str(value)):