def get(self, remote, local=None, keep_dir_structure=False):
        """
        Download a remote file on the fto sever to a local directory.

        :param remote: File path of remote source file
        :param local: Directory of local destination directory
        :param keep_dir_structure: If True, replicates the remote files folder structure
        """
        if local and os.path.isdir(local):
            os.chdir(local)

        elif keep_dir_structure:
            # Replicate the remote files folder structure
            for directory in remote.split(os.sep)[:-1]:
                if not os.path.isdir(directory):
                    os.mkdir(directory)
                os.chdir(directory)

        # Change to the correct directory if remote is a path not just a name
        if os.sep in remote:
            directory, file_name = remote.rsplit(os.sep, 1)
            self.chdir(directory)
        else:
            file_name = remote

        # Download the file and get response
        response = self._retrieve_binary(file_name)

        # Rename downloaded files if local is a file_name string
        if local and isinstance(local, str):
            os.rename(file_name, local)
        return response
def get ( self , remote , local = None , keep_dir_structure = False ) : if local and os . path . isdir ( local ) : os . chdir ( local ) elif keep_dir_structure : for directory in remote . split ( os . sep ) [ : - 1 ] : if not os . path . isdir ( directory ) : os . mkdir ( directory ) os . chdir ( directory ) if os . sep in remote : directory , file_name = remote . rsplit ( os . sep , 1 ) self . chdir ( directory ) else : file_name = remote response = self . _retrieve_binary ( file_name ) if local and isinstance ( local , str ) : os . rename ( file_name , local ) return response
Download a remote file on the fto sever to a local directory.

        :param remote: File path of remote source file
        :param local: Directory of local destination directory
        :param keep_dir_structure: If True, replicates the remote files folder structure