From ab76af3d65812005f254166433efde43554431ad Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 3 Dec 1997 19:34:14 +0000 Subject: [PATCH] Provide default for blocksize on retrbinary (Skip Montanaro). --- Doc/lib/libftplib.tex | 9 +++++---- Doc/libftplib.tex | 9 +++++---- Lib/ftplib.py | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Doc/lib/libftplib.tex b/Doc/lib/libftplib.tex index dfbaa2be071..a89c6a9ecb8 100644 --- a/Doc/lib/libftplib.tex +++ b/Doc/lib/libftplib.tex @@ -125,14 +125,15 @@ Return nothing if a response code in the range 200--299 is received. Raise an exception otherwise. \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 appropriate \samp{RETR} command, i.e.\ \code{"RETR \var{filename}"}. The \var{callback} function is called for each block of data received, with a single string argument giving the data block. -The \var{maxblocksize} argument specifies the maximum block size -(which may not be the actual size of the data blocks passed to -\var{callback}). +The optional \var{maxblocksize} argument specifies the maximum chunk size to +read on the low-level socket object created to do the actual transfer +(which will also be the largest size of the data blocks passed to +\var{callback}). A reasonable default is chosen. \end{funcdesc} \begin{funcdesc}{retrlines}{command\optional{\, callback}} diff --git a/Doc/libftplib.tex b/Doc/libftplib.tex index dfbaa2be071..a89c6a9ecb8 100644 --- a/Doc/libftplib.tex +++ b/Doc/libftplib.tex @@ -125,14 +125,15 @@ Return nothing if a response code in the range 200--299 is received. Raise an exception otherwise. \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 appropriate \samp{RETR} command, i.e.\ \code{"RETR \var{filename}"}. The \var{callback} function is called for each block of data received, with a single string argument giving the data block. -The \var{maxblocksize} argument specifies the maximum block size -(which may not be the actual size of the data blocks passed to -\var{callback}). +The optional \var{maxblocksize} argument specifies the maximum chunk size to +read on the low-level socket object created to do the actual transfer +(which will also be the largest size of the data blocks passed to +\var{callback}). A reasonable default is chosen. \end{funcdesc} \begin{funcdesc}{retrlines}{command\optional{\, callback}} diff --git a/Lib/ftplib.py b/Lib/ftplib.py index ec7d4791ddb..024a0faea4b 100644 --- a/Lib/ftplib.py +++ b/Lib/ftplib.py @@ -317,7 +317,7 @@ def login(self, user = '', passwd = '', acct = ''): raise error_reply, resp return resp - def retrbinary(self, cmd, callback, blocksize): + def retrbinary(self, cmd, callback, blocksize=8192): '''Retrieve data in binary mode. The argument is a RETR command. The callback function is called for each block.