Provide default for blocksize on retrbinary (Skip Montanaro).

This commit is contained in:
Guido van Rossum 1997-12-03 19:34:14 +00:00
parent 98ee50b5a4
commit ab76af3d65
3 changed files with 11 additions and 9 deletions

View File

@ -125,14 +125,15 @@ Return nothing if a response code in the range 200--299 is received.
Raise an exception otherwise. Raise an exception otherwise.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{retrbinary}{command\, callback\, maxblocksize} \begin{funcdesc}{retrbinary}{command\, callback\optional{\, maxblocksize}}
Retrieve a file in binary transfer mode. \var{command} should be an Retrieve a file in binary transfer mode. \var{command} should be an
appropriate \samp{RETR} command, i.e.\ \code{"RETR \var{filename}"}. appropriate \samp{RETR} command, i.e.\ \code{"RETR \var{filename}"}.
The \var{callback} function is called for each block of data received, The \var{callback} function is called for each block of data received,
with a single string argument giving the data block. with a single string argument giving the data block.
The \var{maxblocksize} argument specifies the maximum block size The optional \var{maxblocksize} argument specifies the maximum chunk size to
(which may not be the actual size of the data blocks passed to read on the low-level socket object created to do the actual transfer
\var{callback}). (which will also be the largest size of the data blocks passed to
\var{callback}). A reasonable default is chosen.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{retrlines}{command\optional{\, callback}} \begin{funcdesc}{retrlines}{command\optional{\, callback}}

View File

@ -125,14 +125,15 @@ Return nothing if a response code in the range 200--299 is received.
Raise an exception otherwise. Raise an exception otherwise.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{retrbinary}{command\, callback\, maxblocksize} \begin{funcdesc}{retrbinary}{command\, callback\optional{\, maxblocksize}}
Retrieve a file in binary transfer mode. \var{command} should be an Retrieve a file in binary transfer mode. \var{command} should be an
appropriate \samp{RETR} command, i.e.\ \code{"RETR \var{filename}"}. appropriate \samp{RETR} command, i.e.\ \code{"RETR \var{filename}"}.
The \var{callback} function is called for each block of data received, The \var{callback} function is called for each block of data received,
with a single string argument giving the data block. with a single string argument giving the data block.
The \var{maxblocksize} argument specifies the maximum block size The optional \var{maxblocksize} argument specifies the maximum chunk size to
(which may not be the actual size of the data blocks passed to read on the low-level socket object created to do the actual transfer
\var{callback}). (which will also be the largest size of the data blocks passed to
\var{callback}). A reasonable default is chosen.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{retrlines}{command\optional{\, callback}} \begin{funcdesc}{retrlines}{command\optional{\, callback}}

View File

@ -317,7 +317,7 @@ class FTP:
raise error_reply, resp raise error_reply, resp
return resp return resp
def retrbinary(self, cmd, callback, blocksize): def retrbinary(self, cmd, callback, blocksize=8192):
'''Retrieve data in binary mode. '''Retrieve data in binary mode.
The argument is a RETR command. The argument is a RETR command.
The callback function is called for each block. The callback function is called for each block.