Remove old inp in routine

This commit is contained in:
WQY\qiong
2023-03-21 21:18:53 +08:00
parent 8681a56ed7
commit 9f9d3227b9
28 changed files with 83 additions and 642 deletions

View File

@@ -130,38 +130,9 @@ def delete_pipe(name: str, cs: ChangeSet) -> ChangeSet:
# [OUT]
# id node1 node2 length diam rcoeff lcoeff (status) ;desc
#--------------------------------------------------------------
class InpPipe:
def __init__(self, line: str) -> None:
tokens = line.split()
num = len(tokens)
has_desc = tokens[-1].startswith(';')
num_without_desc = (num - 1) if has_desc else num
self.id = str(tokens[0])
self.node1 = str(tokens[1])
self.node2 = str(tokens[2])
self.length = float(tokens[3])
self.diameter = float(tokens[4])
self.roughness = float(tokens[5])
self.minor_loss = float(tokens[6])
# status is must-have, here fix input
self.status = str(tokens[7].upper()) if num_without_desc >= 8 else PIPE_STATUS_OPEN
self.desc = str(tokens[-1]) if has_desc else None
def inp_in_pipe(section: list[str]) -> ChangeSet:
cs = ChangeSet()
for s in section:
# skip comment
if s.startswith(';'):
continue
obj = InpPipe(s)
cs.append(g_add_prefix | {'type': 'pipe', 'id': obj.id, 'node1': obj.node1, 'node2': obj.node2, 'length': obj.length, 'diameter': obj.diameter, 'roughness': obj.roughness, 'minor_loss': obj.minor_loss, 'status': obj.status})
return cs
def inp_in_pipe_new(line: str) -> str:
def inp_in_pipe(line: str) -> str:
tokens = line.split()
num = len(tokens)