Support inp in link new

This commit is contained in:
WQY\qiong
2023-03-15 22:04:39 +08:00
parent 81c4e0308b
commit 617c66d0cd
6 changed files with 77 additions and 4 deletions

View File

@@ -161,6 +161,28 @@ def inp_in_pipe(section: list[str]) -> ChangeSet:
return cs
def inp_in_pipe_new(name: str, line: str) -> None:
tokens = line.split()
num = len(tokens)
has_desc = tokens[-1].startswith(';')
num_without_desc = (num - 1) if has_desc else num
id = str(tokens[0])
node1 = str(tokens[1])
node2 = str(tokens[2])
length = float(tokens[3])
diameter = float(tokens[4])
roughness = float(tokens[5])
minor_loss = float(tokens[6])
# status is must-have, here fix input
status = str(tokens[7].upper()) if num_without_desc >= 8 else PIPE_STATUS_OPEN
desc = str(tokens[-1]) if has_desc else None
write(name, f"insert into _link (id, type) values ('{id}', 'pipe');")
write(name, f"insert into pipes (id, node1, node2, length, diameter, roughness, minor_loss, status) values ('{id}', '{node1}', '{node2}', {length}, {diameter}, {roughness}, {minor_loss}, '{status}');")
def inp_out_pipe(name: str) -> list[str]:
lines = []
objs = read_all(name, 'select * from pipes')