Parse [RESERVOIRS]

This commit is contained in:
WQY\qiong
2022-11-12 14:51:03 +08:00
parent 749361fd47
commit fb9bef103a
3 changed files with 46 additions and 12 deletions

View File

@@ -138,19 +138,19 @@ class InpJunction:
def inp_in_junction(section: list[str]) -> ChangeSet:
cs = ChangeSet()
for s in section:
junction = InpJunction(s)
cs.append({'operation': API_ADD, 'type': 'junction', 'id': junction.id, 'elevation': junction.elevation, 'demand': junction.demand, 'pattern': junction.pattern})
obj = InpJunction(s)
cs.append({'operation': API_ADD, 'type': 'junction', 'id': obj.id, 'elevation': obj.elevation, 'demand': obj.demand, 'pattern': obj.pattern})
return cs
def inp_out_junction(name: str) -> list[str]:
lines = []
junctions = read_all(name, 'select * from junctions')
for j in junctions:
id = j['id']
elev = j['elevation']
demand = j['demand'] if j['demand'] != None else ''
pattern = j['pattern'] if j['pattern'] != None else ''
objs = read_all(name, 'select * from junctions')
for obj in objs:
id = obj['id']
elev = obj['elevation']
demand = obj['demand'] if obj['demand'] != None else ''
pattern = obj['pattern'] if obj['pattern'] != None else ''
desc = ';'
lines.append(f'{id} {elev} {demand} {pattern} {desc}')
return lines