當前位置: 首頁>>代碼示例>>Python>>正文


Python Files.delete_file方法代碼示例

本文整理匯總了Python中Files.delete_file方法的典型用法代碼示例。如果您正苦於以下問題:Python Files.delete_file方法的具體用法?Python Files.delete_file怎麽用?Python Files.delete_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Files的用法示例。


在下文中一共展示了Files.delete_file方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: tcp_link

# 需要導入模塊: import Files [as 別名]
# 或者: from Files import delete_file [as 別名]

#.........這裏部分代碼省略.........
                break

            elif query == 'create':
                filename = msg['filename']
                error = Files.create_file(filename)
                reply['error'] = error
                if error == 0:
                    Auth.change(filename, name_list[skt], 2, name_list[skt])
                send(skt, json.dumps(reply))

            elif query == 'edit':
                filename = msg['filename']
                if not Files.exist(filename):
                    reply['error'] = 1
                    send(skt, json.dumps(reply))
                    continue
                if not Auth.have_edit_auth(filename, name_list[skt]):
                    reply['error'] = 2
                    send(skt, json.dumps(reply))
                    continue
                reply['error'] = 0
                send(skt, json.dumps(reply))
                reply.clear()
                reply['type'] = 'edit_content'
                reply['filename'] = 'filename'
                reply['isend'] = 1
                content = dict()
                content['oldRange'] = {'start': {'row': 0, 'column': 0}, 'end': {'row': 0, 'column': 0}}
                content['oldText'] = ''
                (file_content, r, c) = Files.edit_file(filename)
                content['newText'] = file_content
                content['newRange'] = {'start': {'row': 0, 'column': 0}, 'end': {'row': r, 'column': c}}
                reply['content'] = content
                send(skt, json.dump(reply))

                Files.add_editor(filename, skt)

            elif query == 'upload':
                filename = msg['filename']
                error = Files.create_file(filename)
                reply['error'] = error
                send(skt, json.dumps(reply))
                if error == 1:
                    continue
                upload_filename = filename
                Auth.change(filename, name_list[sock], 2, name_list[skt])

            elif query == 'upload_content':
                if upload_filename == '':
                    continue
                Files.up_file(upload_filename, msg['content']['newText'])
                upload_filename = ''
                pass

            elif query == 'change_auth':
                filename = msg['filename']
                other_name = msg['other_name']
                if not Files.exist(filename):
                    reply['error'] = 1
                    send(skt, json.dumps(reply))
                    continue
                if not Auth.have_manage_auth(filename, other_name):
                    reply['error'] = 2
                    send(skt, json.dumps(reply))
                    continue
                reply['error'] = 0
                Auth.change(filename, other_name, msg['auth'])
                send(skt, json.dumps(reply))
                pass

            elif query == 'rm':
                filename = msg['filename']
                if not Files.exist(filename):
                    reply['error'] = 1
                    send(skt, json.dumps(reply))
                    continue
                if not Auth.have_manage_auth(filename, name_list[skt]):
                    reply['error'] = 2
                    send(skt, json.dumps(reply))
                    continue
                reply['error'] = 0
                Files.delete_file(filename)
                send(skt, json.dumps(reply))

            elif query == 'ls':
                reply['list'] = Auth.get_edit_list(name_list[skt])
                send(skt, json.dumps(reply))
                pass

            elif query == 'close':
                Files.del_editor(msg['filename'], skt)

            elif query == 'modify':
                modify = msg['content']
                filename = msg['filename']
                send_to_all(skt, json.dumps(modify), filename)
                Files.change_file(filename, modify)

    skt.close()
    print('Connection from %s:%s closed.' % addr)
開發者ID:nsknojj,項目名稱:Birdway-Server,代碼行數:104,代碼來源:Main.py


注:本文中的Files.delete_file方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。