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

@@ -125,34 +125,9 @@ def delete_junction(name: str, cs: ChangeSet) -> ChangeSet:
# [OUT]
# id elev. * * minpressure fullpressure
#--------------------------------------------------------------
class InpJunction:
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.elevation = float(tokens[1])
self.demand = float(tokens[2]) if num_without_desc >= 3 else None
self.pattern = str(tokens[3]) if num_without_desc >= 4 else None
self.desc = str(tokens[-1]) if has_desc else None
def inp_in_junction(section: list[str]) -> ChangeSet:
cs = ChangeSet()
for s in section:
# skip comment
if s.startswith(';'):
continue
obj = InpJunction(s)
cs.append(g_add_prefix | {'type': 'junction', 'id': obj.id, 'elevation': obj.elevation, 'demand': obj.demand, 'pattern': obj.pattern})
cs.append(g_update_prefix | { 'type': 'demand', 'junction': obj.id, 'demands': [{'demand': obj.demand, 'pattern': obj.pattern, 'category': None}] })
return cs
def inp_in_junction_new(line: str, demand_outside: bool) -> str:
def inp_in_junction(line: str, demand_outside: bool) -> str:
tokens = line.split()
num = len(tokens)