コード例 #1
0
ファイル: file.py プロジェクト: khalidhsu/Python-K.Drive-SDK
 def cp(self, _to_path):
     if len(_to_path) > 255: raise Exception("To path too long.")
     params = dict(
                   root=self.root,
                   from_path=self.path,
                   to_path=_to_path,
                   )
     send(cp_url(), params)
コード例 #2
0
ファイル: file.py プロジェクト: khalidhsu/Python-K.Drive-SDK
 def rm(self, to_recycle=True):
     if not self.path:
         raise Exception("Remove root is not allowed/too dangerous, please goto kuaipan.cn and do it there.")
     params = dict(
                   root=self.root,
                   path=self.path,
                   )
     if not to_recycle:
         params["to_recycle"] = "False"
     send(rm_url(), params)
コード例 #3
0
ファイル: file.py プロジェクト: khalidhsu/Python-K.Drive-SDK
 def mv(self, _to_path):
     if len(_to_path) > 255: raise Exception("To path too long.")
     params = dict(
                   root=self.root,
                   from_path=self.path,
                   to_path=_to_path,
                   )
     mv_data = send(mv_url(), params)
     if mv_data:
         self.path = _to_path
コード例 #4
0
 def mkdir(self, _path):
     new_path = self.check_path(_path)        
     params = dict(
                   root=self.root,
                   path=new_path
                   )
     mkdir_data = send(mkdir_url(), params)
     if mkdir_data:
         _id = mkdir_data["file_id"]        
         return kfolder(new_path, _path, _id, self.root)
     return None    
コード例 #5
0
    def ls(self):
        params = dict(
                      page=str(self.page), 
                      page_size=str(self.page_size),
#                      filter_ext=self.filter_ext, sort_by=self.sort_by
#                       sort_by=sort_by
                       )
        ls_data = send(ls_url(root=self.root, path=self.path), params)
        files, folders = [], []
        if ls_data:
            for _file in ls_data["files"]:
                _name = _file['name']
                _is_deleted = _file['is_deleted']
                _id = _file['file_id']
                
                if not _is_deleted:
                    if _file["type"] == "folder":
                        _folder = kfolder(self.path, _name, _id, self.root, )
                        folders.append(_folder)
                    elif _file["type"] == "file":
                        files.append(kfile(self.root, self.path, _name, _id))
        
        return folders, files