def get(self, remotepath, localpath, callback=None):
fr = self.file(remotepath, '<STR_LIT:rb>')<EOL>file_size = self.stat(remotepath).st_size<EOL>fr.prefetch()<EOL>try:<EOL><INDENT>fl = file(localpath, '<STR_LIT:wb>')<EOL>try:<EOL><INDENT>size = <NUM_LIT:0><EOL>while True:<EOL><INDENT>data = fr.read(<NUM_LIT>)<EOL>if len(data) == <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>fl.write(data)<EOL>size += len(data)<EOL>if callback is not None:<EOL><INDENT>callback(size, file_size)<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>fl.close()<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>fr.close()<EOL><DEDENT>s = os.stat(localpath)<EOL>if s.st_size != size:<EOL><INDENT>raise IOError('<STR_LIT>' % (s.st_size, size))<EOL><DEDENT>
Copy a remote file (C{remotepath}) from the SFTP server to the local
host as C{localpath}.  Any exception raised by operations will be
passed through.  This method is primarily provided as a convenience.

@param remotepath: the remote file to copy
@type remotepath: str
@param localpath: the destination path on the local host
@type localpath: str
@param callback: optional callback function that accepts the bytes
    transferred so far and the total bytes to be transferred
    (since 1.7.4)
@type callback: function(int, int)

@since: 1.4