Changeset 101

Show
Ignore:
Timestamp:
2002-03-29 18:34:38 (7 years ago)
Author:
schwa
Message:
FTP: added some method heads with their docstrings from ftplib.FTP .
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/_mock_ftplib.py

    r96 r101  
    3030# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 
    32 # $Id: _mock_ftplib.py,v 1.1 2002/03/29 16:31:20 schwa Exp $ 
     32# $Id: _mock_ftplib.py,v 1.2 2002/03/29 18:34:38 schwa Exp $ 
    3333 
    3434""" 
    3535This module implements a mock version of the standard libraries 
    36 ftplib.py module. 
     36ftplib.py module. Some code is taken from there. 
    3737 
    3838Not all functionality is implemented, only that which is used to 
     
    4040""" 
    4141 
     42class FTP: 
     43    """ 
     44    Mock implementation of ftplib.FTP . For information on mock 
     45    objects see http://www.mockobjects.com/ . 
     46    """ 
     47    def __init__(self, host, user, password): 
     48        self._host = host 
     49        self._user = user 
     50        self._password = password 
     51 
     52    def voidresp(self): 
     53        """Expect a response beginning with '2'.""" 
     54     
     55    def sendcmd(self, cmd): 
     56        """Send a command and return the response.""" 
     57     
     58    def voidcmd(self, cmd): 
     59        """Send a command and expect a response beginning with '2'.""" 
     60 
     61    def ntransfercmd(self, cmd, rest=None): 
     62        """Initiate a transfer over the data connection. 
     63 
     64        If the transfer is active, send a port command and the 
     65        transfer command, and accept the connection.  If the server is 
     66        passive, send a pasv command, connect to it, and start the 
     67        transfer command.  Either way, return the socket for the 
     68        connection and the expected size of the transfer.  The 
     69        expected size may be None if it could not be determined. 
     70 
     71        Optional `rest' argument can be a string that is sent as the 
     72        argument to a RESTART command.  This is essentially a server 
     73        marker used to tell the server to skip over any data up to the 
     74        given marker. 
     75        """ 
     76 
     77    def transfercmd(self, cmd, rest=None): 
     78        """Like ntransfercmd() but returns only the socket.""" 
     79        return self.ntransfercmd(cmd, rest)[0] 
     80 
     81    def dir(self, *args): 
     82        """List a directory in long form. 
     83        By default list current directory to stdout. 
     84        Optional last argument is callback function; all 
     85        non-empty arguments before it are concatenated to the 
     86        LIST command.  (This *should* only be used for a pathname.)""" 
     87 
     88    def rename(self, fromname, toname): 
     89        """Rename a file.""" 
     90 
     91    def delete(self, filename): 
     92        """Delete a file.""" 
     93 
     94    def cwd(self, dirname): 
     95        """Change to a directory.""" 
     96 
     97    def mkd(self, dirname): 
     98        """Make a directory, return its full pathname.""" 
     99 
     100    def rmd(self, dirname): 
     101        """Remove a directory.""" 
     102 
     103    def pwd(self): 
     104        """Return current working directory.""" 
     105 
     106    def quit(self): 
     107        """Quit, and close the connection.""" 
     108 
     109    def close(self): 
     110        """Close the connection without assuming anything about it.""" 
     111