Support inp in link new
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user