- Several methods of nntplib.NNTP have grown an optional file argument

which specifies a file where to divert the command's output
  (already supported by the body() method).  (SF patch #720468)
  Thanks to Terry Carroll.
This commit is contained in:
Guido van Rossum 2003-04-19 18:04:57 +00:00
parent 8d98d2cb95
commit a26854095b
4 changed files with 69 additions and 22 deletions

View file

@ -132,23 +132,35 @@ logging each line sent and received on the connection (including
message text).
\end{methoddesc}
\begin{methoddesc}{newgroups}{date, time}
\begin{methoddesc}{newgroups}{date, time, \optional{file}}
Send a \samp{NEWGROUPS} command. The \var{date} argument should be a
string of the form \code{'\var{yy}\var{mm}\var{dd}'} indicating the
date, and \var{time} should be a string of the form
\code{'\var{hh}\var{mm}\var{ss}'} indicating the time. Return a pair
\code{(\var{response}, \var{groups})} where \var{groups} is a list of
group names that are new since the given date and time.
If the \var{file} parameter is supplied, then the output of the
\samp{NEWGROUPS} command is stored in a file. If \var{file} is a string,
then the method will open a file object with that name, write to it
then close it. If \var{file} is a file object, then it will start
calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
\begin{methoddesc}{newnews}{group, date, time}
\begin{methoddesc}{newnews}{group, date, time, \optional{file}}
Send a \samp{NEWNEWS} command. Here, \var{group} is a group name or
\code{'*'}, and \var{date} and \var{time} have the same meaning as for
\method{newgroups()}. Return a pair \code{(\var{response},
\var{articles})} where \var{articles} is a list of article ids.
If the \var{file} parameter is supplied, then the output of the
\samp{NEWNEWS} command is stored in a file. If \var{file} is a string,
then the method will open a file object with that name, write to it
then close it. If \var{file} is a file object, then it will start
calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
\begin{methoddesc}{list}{}
\begin{methoddesc}{list}{\optional{file}}
Send a \samp{LIST} command. Return a pair \code{(\var{response},
\var{list})} where \var{list} is a list of tuples. Each tuple has the
form \code{(\var{group}, \var{last}, \var{first}, \var{flag})}, where
@ -157,6 +169,12 @@ and first article numbers (as strings), and \var{flag} is
\code{'y'} if posting is allowed, \code{'n'} if not, and \code{'m'} if
the newsgroup is moderated. (Note the ordering: \var{last},
\var{first}.)
If the \var{file} parameter is supplied, then the output of the
\samp{LIST} command is stored in a file. If \var{file} is a string,
then the method will open a file object with that name, write to it
then close it. If \var{file} is a file object, then it will start
calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
\begin{methoddesc}{group}{name}
@ -168,9 +186,15 @@ the group, \var{last} is the last article number in the group, and
\var{name} is the group name. The numbers are returned as strings.
\end{methoddesc}
\begin{methoddesc}{help}{}
\begin{methoddesc}{help}{\optional{file}}
Send a \samp{HELP} command. Return a pair \code{(\var{response},
\var{list})} where \var{list} is a list of help strings.
If the \var{file} parameter is supplied, then the output of the
\samp{HELP} command is stored in a file. If \var{file} is a string,
then the method will open a file object with that name, write to it
then close it. If \var{file} is a file object, then it will start
calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
\begin{methoddesc}{stat}{id}
@ -205,7 +229,7 @@ the body is stored in a file. If \var{file} is a string, then
the method will open a file object with that name, write to it then close it.
If \var{file} is a file object, then it will start calling
\method{write()} on it to store the lines of the body.
Return as for \method{head()}. If \var{file} is supplied. Then
Return as for \method{head()}. If \var{file} is supplied, then
the returned \var{list} is an empty list.
\end{methoddesc}
@ -218,7 +242,7 @@ for \method{stat()}. Return as for \method{head()}.
Send a \samp{SLAVE} command. Return the server's \var{response}.
\end{methoddesc}
\begin{methoddesc}{xhdr}{header, string}
\begin{methoddesc}{xhdr}{header, string, \optional{file}}
Send an \samp{XHDR} command. This command is not defined in the RFC
but is a common extension. The \var{header} argument is a header
keyword, e.g. \code{'subject'}. The \var{string} argument should have
@ -228,6 +252,12 @@ pair \code{(\var{response}, \var{list})}, where \var{list} is a list of
pairs \code{(\var{id}, \var{text})}, where \var{id} is an article id
(as a string) and \var{text} is the text of the requested header for
that article.
If the \var{file} parameter is supplied, then the output of the
\samp{XHDR} command is stored in a file. If \var{file} is a string,
then the method will open a file object with that name, write to it
then close it. If \var{file} is a file object, then it will start
calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
\begin{methoddesc}{post}{file}
@ -251,21 +281,33 @@ This is an optional NNTP extension, and may not be supported by all
servers.
\end{methoddesc}
\begin{methoddesc}{xgtitle}{name}
\begin{methoddesc}{xgtitle}{name, \optional{file}}
Process an \samp{XGTITLE} command, returning a pair \code{(\var{response},
\var{list})}, where \var{list} is a list of tuples containing
\code{(\var{name}, \var{title})}.
% XXX huh? Should that be name, description?
If the \var{file} parameter is supplied, then the output of the
\samp{XGTITLE} command is stored in a file. If \var{file} is a string,
then the method will open a file object with that name, write to it
then close it. If \var{file} is a file object, then it will start
calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
This is an optional NNTP extension, and may not be supported by all
servers.
\end{methoddesc}
\begin{methoddesc}{xover}{start, end}
\begin{methoddesc}{xover}{start, end, \optional{file}}
Return a pair \code{(\var{resp}, \var{list})}. \var{list} is a list
of tuples, one for each article in the range delimited by the \var{start}
and \var{end} article numbers. Each tuple is of the form
\code{(\var{article number}, \var{subject}, \var{poster}, \var{date},
\var{id}, \var{references}, \var{size}, \var{lines})}.
If the \var{file} parameter is supplied, then the output of the
\samp{XOVER} command is stored in a file. If \var{file} is a string,
then the method will open a file object with that name, write to it
then close it. If \var{file} is a file object, then it will start
calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
This is an optional NNTP extension, and may not be supported by all
servers.
\end{methoddesc}