Clean code
This commit is contained in:
@@ -54,7 +54,7 @@ class Pump(object):
|
||||
return { 'type': self.type, 'id': self.id }
|
||||
|
||||
|
||||
def set_pump_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
def _set_pump(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
old = Pump(get_pump(name, cs.operations[0]['id']))
|
||||
raw_new = get_pump(name, cs.operations[0]['id'])
|
||||
|
||||
@@ -79,10 +79,10 @@ def set_pump(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return ChangeSet()
|
||||
if get_pump(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, set_pump_cmd(name, cs))
|
||||
return execute_command(name, _set_pump(name, cs))
|
||||
|
||||
|
||||
def add_pump_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
def _add_pump(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
new = Pump(cs.operations[0])
|
||||
|
||||
redo_sql = f"insert into _link (id, type) values ({new.f_id}, {new.f_type});"
|
||||
@@ -102,10 +102,10 @@ def add_pump(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return ChangeSet()
|
||||
if get_pump(name, cs.operations[0]['id']) != {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, add_pump_cmd(name, cs))
|
||||
return execute_command(name, _add_pump(name, cs))
|
||||
|
||||
|
||||
def delete_pump_cmd(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
def _delete_pump(name: str, cs: ChangeSet) -> DbChangeSet:
|
||||
old = Pump(get_pump(name, cs.operations[0]['id']))
|
||||
|
||||
redo_sql = f"delete from pumps where id = {old.f_id};"
|
||||
@@ -125,7 +125,7 @@ def delete_pump(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
return ChangeSet()
|
||||
if get_pump(name, cs.operations[0]['id']) == {}:
|
||||
return ChangeSet()
|
||||
return execute_command(name, delete_pump_cmd(name, cs))
|
||||
return execute_command(name, _delete_pump(name, cs))
|
||||
|
||||
|
||||
#--------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user