返回目标文件可用的下载地址
        :param remote_path: 每一项代表需要下载的文件路径
        :type remote_path: str list
188809
def download_url(self, remote_path, **kwargs):
        

        def get_url(dlink):
            return self.session.get(dlink,
                                    headers=BAIDUPAN_HEADERS,
                                    stream=True).url

        if not hasattr(self, 'dsign'):
            self.get_sign()

        if isinstance(remote_path, str) or isinstance(remote_path, str):
            remote_path = [remote_path]

        file_list = []
        jdata = json.loads(self.meta(remote_path).content)
        if jdata['errno'] != 0:
            jdata = self.__err_handler('generic', jdata['errno'],
                                       self.meta,
                                       args=(remote_path,)
                                       )
        logging.debug('[*]' + str(jdata))
        for i, entry in enumerate(jdata['info']):
            url = entry['dlink']
            foo = get_url(url)
            if 'wenxintishi' in foo:
                file_list.append(self._yunguanjia_format(remote_path[i]))
            else:
                file_list.append(get_url(entry['dlink']))

        return file_list
660165
def remote_list(timestamps=True):
    
    r = get_remote_file(DICTS_URL)
    lst = []
    for f in r.text.split('\n'):
        if not f:
            continue
        name, date = f.split(':')
        name = name.replace('.txt', '')
        lst.append((name, int(date)) if timestamps else name)

    return lst
82030
def Remote(path=None, loader=Notebook, **globals):
    

    class Remote(RemoteMixin, loader):
        ...

    return Remote(path=path, **globals)
4815
def get_path_url(path, relative=False):
    
    if relative:
        return os.path.relpath(path)
    else:
        return 'file://%s' % os.path.abspath(path)
861792
def _get_relative_pythonpath(self):
        """"""
        # Workaround to replace os.path.relpath (new in Python v2.6):
        offset = len(self.root_path)+len(os.pathsep)
        return [path[offset:] for path in self.pythonpath]
1107972
def get_repo_paths(path):
    
    repo_paths = []
    dirnames = (os.path.abspath(dirname) for dirname in os.listdir(path))
    for dirname in dirnames:
        try:
            get_scm(dirname)
            repo_paths.append(dirname)
        except VCSError:
            pass
    return repo_paths
1323909
def get_remote_content(filepath):
        
        with hide('running'):
            temp = BytesIO()
            get(filepath, temp)
            content = temp.getvalue().decode('utf-8')
        return content.strip()
957391
def _locatedownload(self, remote_path, **kwargs):
        
        params = {
            'path': remote_path
        }
        url = 'https://{0}/rest/2.0/pcs/file'.format(BAIDUPCS_SERVER)
        return self._request('file', 'locatedownload', url=url,
                             extra_params=params, **kwargs)
577627
def get_remote_url(path, remote="origin"):
    
    path = get_path(path)
    cmd = ["config", "--get", "remote.%s.url" % remote]
    return __run_git(cmd, path)[0]
996310
def get_file_list(path):
    
    f_list = []
    def recur_dir(path, newpath = os.path.sep):
        files = os.listdir(path)
        for fle in files:
            f_path = cpjoin(path, fle)
            if os.path.isdir(f_path): recur_dir(f_path, cpjoin(newpath, fle))
            elif os.path.isfile(f_path): f_list.append(get_single_file_info(f_path, cpjoin(newpath, fle)))

    recur_dir(path)
    return f_list
190914
def local_cache_path(remote_url):
    """"""
    local_name = RESERVED_PATH_CHARS.sub("_", remote_url)
    return os.path.join(gettempdir(), local_name)
128329
def import_path(self):
    """"""
    return os.path.join(self.remote_root, self.pkg) if self.pkg else self.remote_root
1006035
def _get_parent_remote_paths(self):
        
        parent_paths = set([item.get_remote_parent_path() for item in self.file_urls])
        if '' in parent_paths:
            parent_paths.remove('')
        return parent_paths
909738
def path_enabled?(remote)
      dir = workspace_of(remote)
      File.exist?(dir) && symlink?(dir)
    end
285430
def get(self, remote_file, local_file):
        
        sftp = self.get_sftp()
        try:
            sftp.get(remote_file, local_file)
        except Exception as e:
            logger.error('下载文件失败')
            logger.error('remote: %s, local: %s' % (remote_file, local_file))
            logger.error(e)
143368
def list_remote(remote_uri, verbose=False):
    
    remote_uri1, remote_dpath = remote_uri.split(':')
    if not remote_dpath:
        remote_dpath = '.'
    import utool as ut
    out = ut.cmd('ssh', remote_uri1, 'ls -l %s' % (remote_dpath,), verbose=verbose)
    import re
    # Find lines that look like ls output
    split_lines = [re.split(r'\s+', t) for t in out[0].split('\n')]
    paths = [' '.join(t2[8:]) for t2 in split_lines if len(t2) > 8]
    return paths
237274
def restore(self, remotepath):
		''' 
		'''
		rpath = get_pcs_path(remotepath)
		# by default, only 1000 items, more than that sounds a bit crazy
		pars = {
			'method' : 'listrecycle' }

		self.pd("Searching for fs_id to restore")
		return self.__get(pcsurl + 'file', pars, self.__restore_search_act, rpath)