Clean code

This commit is contained in:
WQY\qiong
2023-04-29 15:01:11 +08:00
parent a0166193ef
commit 35d2ce08e1
29 changed files with 133 additions and 375 deletions

View File

@@ -63,7 +63,7 @@ class Pipe(object):
return { 'type': self.type, 'id': self.id }
def set_pipe_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
def _set_pipe(name: str, cs: ChangeSet) -> DbChangeSet:
old = Pipe(get_pipe(name, cs.operations[0]['id']))
raw_new = get_pipe(name, cs.operations[0]['id'])
@@ -88,10 +88,10 @@ def set_pipe(name: str, cs: ChangeSet) -> ChangeSet:
return ChangeSet()
if get_pipe(name, cs.operations[0]['id']) == {}:
return ChangeSet()
return execute_command(name, set_pipe_cmd(name, cs))
return execute_command(name, _set_pipe(name, cs))
def add_pipe_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
def _add_pipe(name: str, cs: ChangeSet) -> DbChangeSet:
new = Pipe(cs.operations[0])
redo_sql = f"insert into _link (id, type) values ({new.f_id}, {new.f_type});"
@@ -111,10 +111,10 @@ def add_pipe(name: str, cs: ChangeSet) -> ChangeSet:
return ChangeSet()
if get_pipe(name, cs.operations[0]['id']) != {}:
return ChangeSet()
return execute_command(name, add_pipe_cmd(name, cs))
return execute_command(name, _add_pipe(name, cs))
def delete_pipe_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
def _delete_pipe(name: str, cs: ChangeSet) -> DbChangeSet:
old = Pipe(get_pipe(name, cs.operations[0]['id']))
redo_sql = f"delete from pipes where id = {old.f_id};"
@@ -134,7 +134,7 @@ def delete_pipe(name: str, cs: ChangeSet) -> ChangeSet:
return ChangeSet()
if get_pipe(name, cs.operations[0]['id']) == {}:
return ChangeSet()
return execute_command(name, delete_pipe_cmd(name, cs))
return execute_command(name, _delete_pipe(name, cs))
#--------------------------------------------------------------