blob: a2161ceaa45527a16e7d7f97638a51d3f8fdda95 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{nntplib} ---
Fred Drakedd6c6d91999-04-22 16:45:26 +00002 NNTP protocol client}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drakedd6c6d91999-04-22 16:45:26 +00004\declaremodule{standard}{nntplib}
Fred Drakeb91e9341998-07-23 17:59:49 +00005\modulesynopsis{NNTP protocol client (requires sockets).}
6
Fred Drake6279fcc1998-01-07 13:23:32 +00007\indexii{NNTP}{protocol}
Fred Drake3f6034d1998-07-02 19:33:43 +00008\index{Network News Transfer Protocol}
Guido van Rossum86751151995-02-28 17:14:32 +00009
Fred Drakefc576191998-04-04 07:15:02 +000010This module defines the class \class{NNTP} which implements the client
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000011side of the NNTP protocol. It can be used to implement a news reader
12or poster, or automated news processors. For more information on NNTP
Fred Drakec5891241998-02-09 19:16:20 +000013(Network News Transfer Protocol), see Internet \rfc{977}.
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000014
Guido van Rossum1b91cda1995-03-24 15:56:02 +000015Here are two small examples of how it can be used. To list some
16statistics about a newsgroup and print the subjects of the last 10
17articles:
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000018
Fred Drake19479911998-02-13 06:58:54 +000019\begin{verbatim}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000020>>> s = NNTP('news.cwi.nl')
21>>> resp, count, first, last, name = s.group('comp.lang.python')
22>>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last
23Group comp.lang.python has 59 articles, range 3742 to 3803
24>>> resp, subs = s.xhdr('subject', first + '-' + last)
25>>> for id, sub in subs[-10:]: print id, sub
26...
273792 Re: Removing elements from a list while iterating...
283793 Re: Who likes Info files?
293794 Emacs and doc strings
303795 a few questions about the Mac implementation
313796 Re: executable python scripts
323797 Re: executable python scripts
333798 Re: a few questions about the Mac implementation
343799 Re: PROPOSAL: A Generic Python Object Interface for Python C Modules
353802 Re: executable python scripts
Fred Drake65b32f71998-02-09 20:27:12 +0000363803 Re: \POSIX{} wait and SIGCHLD
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000037>>> s.quit()
38'205 news.cwi.nl closing connection. Goodbye.'
Fred Drake19479911998-02-13 06:58:54 +000039\end{verbatim}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000040
41To post an article from a file (this assumes that the article has
42valid headers):
43
Fred Drake19479911998-02-13 06:58:54 +000044\begin{verbatim}
Guido van Rossumcca8d2b1995-03-22 15:48:46 +000045>>> s = NNTP('news.cwi.nl')
46>>> f = open('/tmp/article')
47>>> s.post(f)
48'240 Article posted successfully.'
49>>> s.quit()
50'205 news.cwi.nl closing connection. Goodbye.'
Fred Drake19479911998-02-13 06:58:54 +000051\end{verbatim}
Fred Drakedd6c6d91999-04-22 16:45:26 +000052
Guido van Rossum1b91cda1995-03-24 15:56:02 +000053The module itself defines the following items:
54
Fred Drakec46973c1998-11-16 17:11:30 +000055\begin{classdesc}{NNTP}{host\optional{, port
Barry Warsaw41d84632000-02-10 20:26:45 +000056 \optional{, user\optional{, password
57 \optional{, readermode}}}}}
Fred Drakefc576191998-04-04 07:15:02 +000058Return a new instance of the \class{NNTP} class, representing a
Guido van Rossum1b91cda1995-03-24 15:56:02 +000059connection to the NNTP server running on host \var{host}, listening at
Fred Drakec46973c1998-11-16 17:11:30 +000060port \var{port}. The default \var{port} is 119. If the optional
Eric S. Raymond2852cba2002-12-31 15:28:44 +000061\var{user} and \var{password} are provided,
62or if suitable credentials are present in \file{~/.netrc},
63the \samp{AUTHINFO USER} and \samp{AUTHINFO PASS} commands are used to
Barry Warsaw41d84632000-02-10 20:26:45 +000064identify and authenticate the user to the server. If the optional
65flag \var{readermode} is true, then a \samp{mode reader} command is
66sent before authentication is performed. Reader mode is sometimes
67necessary if you are connecting to an NNTP server on the local machine
68and intend to call reader-specific commands, such as \samp{group}. If
69you get unexpected \code{NNTPPermanentError}s, you might need to set
70\var{readermode}. \var{readermode} defaults to \code{None}.
Fred Drakefc576191998-04-04 07:15:02 +000071\end{classdesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +000072
Barry Warsaw41d84632000-02-10 20:26:45 +000073\begin{classdesc}{NNTPError}{}
74Derived from the standard exception \code{Exception}, this is the base
75class for all exceptions raised by the \code{nntplib} module.
76\end{classdesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +000077
Barry Warsaw41d84632000-02-10 20:26:45 +000078\begin{classdesc}{NNTPReplyError}{}
79Exception raised when an unexpected reply is received from the
80server. For backwards compatibility, the exception \code{error_reply}
81is equivalent to this class.
82\end{classdesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +000083
Barry Warsaw41d84632000-02-10 20:26:45 +000084\begin{classdesc}{NNTPTemporaryError}{}
85Exception raised when an error code in the range 400--499 is
86received. For backwards compatibility, the exception
87\code{error_temp} is equivalent to this class.
88\end{classdesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +000089
Barry Warsaw41d84632000-02-10 20:26:45 +000090\begin{classdesc}{NNTPPermanentError}{}
91Exception raised when an error code in the range 500--599 is
92received. For backwards compatibility, the exception
93\code{error_perm} is equivalent to this class.
94\end{classdesc}
95
96\begin{classdesc}{NNTPProtocolError}{}
Guido van Rossum1b91cda1995-03-24 15:56:02 +000097Exception raised when a reply is received from the server that does
Barry Warsaw41d84632000-02-10 20:26:45 +000098not begin with a digit in the range 1--5. For backwards
99compatibility, the exception \code{error_proto} is equivalent to this
100class.
101\end{classdesc}
102
103\begin{classdesc}{NNTPDataError}{}
104Exception raised when there is some error in the response data. For
105backwards compatibility, the exception \code{error_data} is
106equivalent to this class.
107\end{classdesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000108
Fred Drakefc576191998-04-04 07:15:02 +0000109
Fred Drakedd6c6d91999-04-22 16:45:26 +0000110\subsection{NNTP Objects \label{nntp-objects}}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000111
112NNTP instances have the following methods. The \var{response} that is
113returned as the first item in the return tuple of almost all methods
114is the server's response: a string beginning with a three-digit code.
115If the server's response indicates an error, the method raises one of
116the above exceptions.
117
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000118
Fred Drakefc576191998-04-04 07:15:02 +0000119\begin{methoddesc}{getwelcome}{}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000120Return the welcome message sent by the server in reply to the initial
121connection. (This message sometimes contains disclaimers or help
122information that may be relevant to the user.)
Fred Drakefc576191998-04-04 07:15:02 +0000123\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000124
Fred Drakefc576191998-04-04 07:15:02 +0000125\begin{methoddesc}{set_debuglevel}{level}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000126Set the instance's debugging level. This controls the amount of
Fred Drakefc576191998-04-04 07:15:02 +0000127debugging output printed. The default, \code{0}, produces no debugging
128output. A value of \code{1} produces a moderate amount of debugging
129output, generally a single line per request or response. A value of
130\code{2} or higher produces the maximum amount of debugging output,
131logging each line sent and received on the connection (including
132message text).
133\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000134
Guido van Rossuma2685402003-04-19 18:04:57 +0000135\begin{methoddesc}{newgroups}{date, time, \optional{file}}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000136Send a \samp{NEWGROUPS} command. The \var{date} argument should be a
Fred Drakedd6c6d91999-04-22 16:45:26 +0000137string of the form \code{'\var{yy}\var{mm}\var{dd}'} indicating the
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000138date, and \var{time} should be a string of the form
Fred Drakedd6c6d91999-04-22 16:45:26 +0000139\code{'\var{hh}\var{mm}\var{ss}'} indicating the time. Return a pair
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000140\code{(\var{response}, \var{groups})} where \var{groups} is a list of
141group names that are new since the given date and time.
Guido van Rossuma2685402003-04-19 18:04:57 +0000142If the \var{file} parameter is supplied, then the output of the
143\samp{NEWGROUPS} command is stored in a file. If \var{file} is a string,
144then the method will open a file object with that name, write to it
145then close it. If \var{file} is a file object, then it will start
146calling \method{write()} on it to store the lines of the command output.
147If \var{file} is supplied, then the returned \var{list} is an empty list.
Fred Drakefc576191998-04-04 07:15:02 +0000148\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000149
Guido van Rossuma2685402003-04-19 18:04:57 +0000150\begin{methoddesc}{newnews}{group, date, time, \optional{file}}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000151Send a \samp{NEWNEWS} command. Here, \var{group} is a group name or
Fred Drakefc576191998-04-04 07:15:02 +0000152\code{'*'}, and \var{date} and \var{time} have the same meaning as for
153\method{newgroups()}. Return a pair \code{(\var{response},
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000154\var{articles})} where \var{articles} is a list of article ids.
Guido van Rossuma2685402003-04-19 18:04:57 +0000155If the \var{file} parameter is supplied, then the output of the
156\samp{NEWNEWS} command is stored in a file. If \var{file} is a string,
157then the method will open a file object with that name, write to it
158then close it. If \var{file} is a file object, then it will start
159calling \method{write()} on it to store the lines of the command output.
160If \var{file} is supplied, then the returned \var{list} is an empty list.
Fred Drakefc576191998-04-04 07:15:02 +0000161\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000162
Guido van Rossuma2685402003-04-19 18:04:57 +0000163\begin{methoddesc}{list}{\optional{file}}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000164Send a \samp{LIST} command. Return a pair \code{(\var{response},
165\var{list})} where \var{list} is a list of tuples. Each tuple has the
166form \code{(\var{group}, \var{last}, \var{first}, \var{flag})}, where
167\var{group} is a group name, \var{last} and \var{first} are the last
Fred Drakedd6c6d91999-04-22 16:45:26 +0000168and first article numbers (as strings), and \var{flag} is
169\code{'y'} if posting is allowed, \code{'n'} if not, and \code{'m'} if
170the newsgroup is moderated. (Note the ordering: \var{last},
171\var{first}.)
Guido van Rossuma2685402003-04-19 18:04:57 +0000172If the \var{file} parameter is supplied, then the output of the
173\samp{LIST} command is stored in a file. If \var{file} is a string,
174then the method will open a file object with that name, write to it
175then close it. If \var{file} is a file object, then it will start
176calling \method{write()} on it to store the lines of the command output.
177If \var{file} is supplied, then the returned \var{list} is an empty list.
Martin v. Löwis8ddb6382004-07-30 16:08:49 +0000178\end{methoddesc}
Martin v. Löwiscc0f9322004-07-26 12:40:50 +0000179
180\begin{methoddesc}{descriptions}{grouppattern}
181Send a \samp{LIST NEWSGROUPS} command, where \var{grouppattern} is a wildmat
182string as specified in RFC2980 (it's essentially the same as DOS or UNIX
183shell wildcard strings). Return a pair \code{(\var{response},
184\var{list})}, where \var{list} is a list of tuples containing
185\code{(\var{name}, \var{title})}.
Martin v. Löwis8ddb6382004-07-30 16:08:49 +0000186
187\versionadded{2.4}
Martin v. Löwiscc0f9322004-07-26 12:40:50 +0000188\end{methoddesc}
189
190\begin{methoddesc}{description}{group}
191Get a description for a single group \var{group}. If more than one group
Martin v. Löwis8ddb6382004-07-30 16:08:49 +0000192matches (if 'group' is a real wildmat string), return the first match.
193If no group matches, return an empty string.
Martin v. Löwiscc0f9322004-07-26 12:40:50 +0000194
195This elides the response code from the server. If the response code is
196needed, use \method{descriptions()}.
197
Martin v. Löwis8ddb6382004-07-30 16:08:49 +0000198\versionadded{2.4}
Fred Drakefc576191998-04-04 07:15:02 +0000199\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000200
Fred Drakefc576191998-04-04 07:15:02 +0000201\begin{methoddesc}{group}{name}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000202Send a \samp{GROUP} command, where \var{name} is the group name.
Fred Drakedd6c6d91999-04-22 16:45:26 +0000203Return a tuple \code{(\var{response}, \var{count}, \var{first},
204\var{last}, \var{name})} where \var{count} is the (estimated) number
205of articles in the group, \var{first} is the first article number in
206the group, \var{last} is the last article number in the group, and
207\var{name} is the group name. The numbers are returned as strings.
Fred Drakefc576191998-04-04 07:15:02 +0000208\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000209
Guido van Rossuma2685402003-04-19 18:04:57 +0000210\begin{methoddesc}{help}{\optional{file}}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000211Send a \samp{HELP} command. Return a pair \code{(\var{response},
212\var{list})} where \var{list} is a list of help strings.
Guido van Rossuma2685402003-04-19 18:04:57 +0000213If the \var{file} parameter is supplied, then the output of the
214\samp{HELP} command is stored in a file. If \var{file} is a string,
215then the method will open a file object with that name, write to it
216then close it. If \var{file} is a file object, then it will start
217calling \method{write()} on it to store the lines of the command output.
218If \var{file} is supplied, then the returned \var{list} is an empty list.
Fred Drakefc576191998-04-04 07:15:02 +0000219\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000220
Fred Drakefc576191998-04-04 07:15:02 +0000221\begin{methoddesc}{stat}{id}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000222Send a \samp{STAT} command, where \var{id} is the message id (enclosed
Fred Drakefc576191998-04-04 07:15:02 +0000223in \character{<} and \character{>}) or an article number (as a string).
Fred Drake4b3f0311996-12-13 22:04:31 +0000224Return a triple \code{(\var{response}, \var{number}, \var{id})} where
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000225\var{number} is the article number (as a string) and \var{id} is the
Fred Drakefc576191998-04-04 07:15:02 +0000226article id (enclosed in \character{<} and \character{>}).
227\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000228
Fred Drakefc576191998-04-04 07:15:02 +0000229\begin{methoddesc}{next}{}
230Send a \samp{NEXT} command. Return as for \method{stat()}.
231\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000232
Fred Drakefc576191998-04-04 07:15:02 +0000233\begin{methoddesc}{last}{}
234Send a \samp{LAST} command. Return as for \method{stat()}.
235\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000236
Fred Drakefc576191998-04-04 07:15:02 +0000237\begin{methoddesc}{head}{id}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000238Send a \samp{HEAD} command, where \var{id} has the same meaning as for
Guido van Rossumcd905091998-06-30 14:53:41 +0000239\method{stat()}. Return a tuple
240\code{(\var{response}, \var{number}, \var{id}, \var{list})}
241where the first three are the same as for \method{stat()},
242and \var{list} is a list of the article's headers (an uninterpreted
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000243list of lines, without trailing newlines).
Fred Drakefc576191998-04-04 07:15:02 +0000244\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000245
Fredrik Lundha5e61652001-10-18 20:58:25 +0000246\begin{methoddesc}{body}{id,\optional{file}}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000247Send a \samp{BODY} command, where \var{id} has the same meaning as for
Fredrik Lundha5e61652001-10-18 20:58:25 +0000248\method{stat()}. If the \var{file} parameter is supplied, then
249the body is stored in a file. If \var{file} is a string, then
Guido van Rossume7877df2001-10-01 13:50:15 +0000250the method will open a file object with that name, write to it then close it.
Fredrik Lundha5e61652001-10-18 20:58:25 +0000251If \var{file} is a file object, then it will start calling
Guido van Rossume7877df2001-10-01 13:50:15 +0000252\method{write()} on it to store the lines of the body.
Guido van Rossuma2685402003-04-19 18:04:57 +0000253Return as for \method{head()}. If \var{file} is supplied, then
Guido van Rossume7877df2001-10-01 13:50:15 +0000254the returned \var{list} is an empty list.
Fred Drakefc576191998-04-04 07:15:02 +0000255\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000256
Fred Drakefc576191998-04-04 07:15:02 +0000257\begin{methoddesc}{article}{id}
Fred Drake506a7a82000-07-01 17:43:19 +0000258Send an \samp{ARTICLE} command, where \var{id} has the same meaning as
Guido van Rossumcd905091998-06-30 14:53:41 +0000259for \method{stat()}. Return as for \method{head()}.
Fred Drakefc576191998-04-04 07:15:02 +0000260\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000261
Fred Drakefc576191998-04-04 07:15:02 +0000262\begin{methoddesc}{slave}{}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000263Send a \samp{SLAVE} command. Return the server's \var{response}.
Fred Drakefc576191998-04-04 07:15:02 +0000264\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000265
Guido van Rossuma2685402003-04-19 18:04:57 +0000266\begin{methoddesc}{xhdr}{header, string, \optional{file}}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000267Send an \samp{XHDR} command. This command is not defined in the RFC
268but is a common extension. The \var{header} argument is a header
Fred Drakefc576191998-04-04 07:15:02 +0000269keyword, e.g. \code{'subject'}. The \var{string} argument should have
Fred Drakedd6c6d91999-04-22 16:45:26 +0000270the form \code{'\var{first}-\var{last}'} where \var{first} and
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000271\var{last} are the first and last article numbers to search. Return a
272pair \code{(\var{response}, \var{list})}, where \var{list} is a list of
273pairs \code{(\var{id}, \var{text})}, where \var{id} is an article id
274(as a string) and \var{text} is the text of the requested header for
275that article.
Guido van Rossuma2685402003-04-19 18:04:57 +0000276If the \var{file} parameter is supplied, then the output of the
277\samp{XHDR} command is stored in a file. If \var{file} is a string,
278then the method will open a file object with that name, write to it
279then close it. If \var{file} is a file object, then it will start
280calling \method{write()} on it to store the lines of the command output.
281If \var{file} is supplied, then the returned \var{list} is an empty list.
Fred Drakefc576191998-04-04 07:15:02 +0000282\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000283
Fred Drakefc576191998-04-04 07:15:02 +0000284\begin{methoddesc}{post}{file}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000285Post an article using the \samp{POST} command. The \var{file}
286argument is an open file object which is read until EOF using its
Fred Drakefc576191998-04-04 07:15:02 +0000287\method{readline()} method. It should be a well-formed news article,
288including the required headers. The \method{post()} method
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000289automatically escapes lines beginning with \samp{.}.
Fred Drakefc576191998-04-04 07:15:02 +0000290\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000291
Fred Drakefc576191998-04-04 07:15:02 +0000292\begin{methoddesc}{ihave}{id, file}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000293Send an \samp{IHAVE} command. If the response is not an error, treat
Fred Drakefc576191998-04-04 07:15:02 +0000294\var{file} exactly as for the \method{post()} method.
295\end{methoddesc}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000296
Fred Drakefc576191998-04-04 07:15:02 +0000297\begin{methoddesc}{date}{}
Guido van Rossum94adab51997-06-02 17:27:50 +0000298Return a triple \code{(\var{response}, \var{date}, \var{time})},
299containing the current date and time in a form suitable for the
Fred Drakefc576191998-04-04 07:15:02 +0000300\method{newnews()} and \method{newgroups()} methods.
Guido van Rossum94adab51997-06-02 17:27:50 +0000301This is an optional NNTP extension, and may not be supported by all
302servers.
Fred Drakefc576191998-04-04 07:15:02 +0000303\end{methoddesc}
Guido van Rossum94adab51997-06-02 17:27:50 +0000304
Guido van Rossuma2685402003-04-19 18:04:57 +0000305\begin{methoddesc}{xgtitle}{name, \optional{file}}
Fred Drakefc576191998-04-04 07:15:02 +0000306Process an \samp{XGTITLE} command, returning a pair \code{(\var{response},
Fred Drakefac431e1998-02-16 21:57:37 +0000307\var{list})}, where \var{list} is a list of tuples containing
Guido van Rossum94adab51997-06-02 17:27:50 +0000308\code{(\var{name}, \var{title})}.
309% XXX huh? Should that be name, description?
Guido van Rossuma2685402003-04-19 18:04:57 +0000310If the \var{file} parameter is supplied, then the output of the
311\samp{XGTITLE} command is stored in a file. If \var{file} is a string,
312then the method will open a file object with that name, write to it
313then close it. If \var{file} is a file object, then it will start
314calling \method{write()} on it to store the lines of the command output.
315If \var{file} is supplied, then the returned \var{list} is an empty list.
Guido van Rossum94adab51997-06-02 17:27:50 +0000316This is an optional NNTP extension, and may not be supported by all
317servers.
Martin v. Löwiscc0f9322004-07-26 12:40:50 +0000318
319RFC2980 says ``It is suggested that this extension be deprecated''. Use
320\method{descriptions()} or \method{description()} instead.
Fred Drakefc576191998-04-04 07:15:02 +0000321\end{methoddesc}
Guido van Rossum94adab51997-06-02 17:27:50 +0000322
Guido van Rossuma2685402003-04-19 18:04:57 +0000323\begin{methoddesc}{xover}{start, end, \optional{file}}
Guido van Rossum94adab51997-06-02 17:27:50 +0000324Return a pair \code{(\var{resp}, \var{list})}. \var{list} is a list
325of tuples, one for each article in the range delimited by the \var{start}
326and \var{end} article numbers. Each tuple is of the form
Fred Drakedd6c6d91999-04-22 16:45:26 +0000327\code{(\var{article number}, \var{subject}, \var{poster}, \var{date},
328\var{id}, \var{references}, \var{size}, \var{lines})}.
Guido van Rossuma2685402003-04-19 18:04:57 +0000329If the \var{file} parameter is supplied, then the output of the
330\samp{XOVER} command is stored in a file. If \var{file} is a string,
331then the method will open a file object with that name, write to it
332then close it. If \var{file} is a file object, then it will start
333calling \method{write()} on it to store the lines of the command output.
334If \var{file} is supplied, then the returned \var{list} is an empty list.
Guido van Rossum94adab51997-06-02 17:27:50 +0000335This is an optional NNTP extension, and may not be supported by all
336servers.
Fred Drakefc576191998-04-04 07:15:02 +0000337\end{methoddesc}
Guido van Rossum94adab51997-06-02 17:27:50 +0000338
Fred Drakefc576191998-04-04 07:15:02 +0000339\begin{methoddesc}{xpath}{id}
Guido van Rossum94adab51997-06-02 17:27:50 +0000340Return a pair \code{(\var{resp}, \var{path})}, where \var{path} is the
341directory path to the article with message ID \var{id}. This is an
342optional NNTP extension, and may not be supported by all servers.
Fred Drakefc576191998-04-04 07:15:02 +0000343\end{methoddesc}
Guido van Rossum94adab51997-06-02 17:27:50 +0000344
Fred Drakefc576191998-04-04 07:15:02 +0000345\begin{methoddesc}{quit}{}
Guido van Rossum1b91cda1995-03-24 15:56:02 +0000346Send a \samp{QUIT} command and close the connection. Once this method
347has been called, no other methods of the NNTP object should be called.
Fred Drakefc576191998-04-04 07:15:02 +0000348\end{methoddesc}