'Downloads the file(s) described in entry'

def download_entry(self, entry, config, sftp):

    path = (urlparse(entry[u'url']).path or u'.')
    delete_origin = config[u'delete_origin']
    recursive = config[u'recursive']
    to = config[u'to']
    if to:
        try:
            to = render_from_entry(to, entry)
        except RenderError as e:
            log.error((u'Could    not    render    path:    %s' % to))
            entry.fail(e)
            return
    if (not sftp.lexists(path)):
        log.error((u'Remote    path    does    not    exist:    %s' % path))
        return
    if sftp.isfile(path):
        source_file = remotepath.basename(path)
        source_dir = remotepath.dirname(path)
        try:
            sftp.cwd(source_dir)
            self.download_file(source_file, to, sftp, delete_origin)
        except Exception as e:
            error = (u'Failed    to    download    file    %s    (%s)' % (path, e))
            log.error(error)
            entry.fail(error)
    elif sftp.isdir(path):
        base_path = remotepath.normpath(remotepath.join(path, u'..'))
        dir_name = remotepath.basename(path)
        handle_file = partial(self.download_file, dest=to, sftp=sftp, delete_origin=delete_origin)
        try:
            sftp.cwd(base_path)
            sftp.walktree(dir_name, handle_file, self.handle_dir, self.handle_unknown, recursive)
        except Exception as e:
            error = (u'Failed    to    download    directory    %s    (%s)' % (path, e))
            log.error(error)
            entry.fail(error)
            return
        if delete_origin:
            self.remove_dir(sftp, path)
    else:
        log.warning((u'Skipping    unknown    file    %s' % path))
