'Download a file from path to dest'

def download_file(self, path, dest, sftp, delete_origin):

    dir_name = remotepath.dirname(path)
    dest_relpath = localpath.join(*remotepath.split(path))
    destination = localpath.join(dest, dest_relpath)
    dest_dir = localpath.dirname(destination)
    if localpath.exists(destination):
        log.verbose((u'Destination    file    already    exists.    Skipping    %s' % path))
        return
    if (not localpath.exists(dest_dir)):
        os.makedirs(dest_dir)
    log.verbose((u'Downloading    file    %s    to    %s' % (path, destination)))
    try:
        sftp.get(path, destination)
    except Exception as e:
        log.error((u'Failed    to    download    %s    (%s)' % (path, e)))
        if localpath.exists(destination):
            log.debug((u'Removing    partially    downloaded    file    %s' % destination))
            os.remove(destination)
        raise e
    if delete_origin:
        log.debug((u'Deleting    remote    file    %s' % path))
        try:
            sftp.remove(path)
        except Exception as e:
            log.error((u'Failed    to    delete    file    %s    (%s)' % (path, e)))
            return
        self.remove_dir(sftp, dir_name)
