Support inp in tag, demand, status
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from .project import *
|
||||
from .database import ChangeSet, write
|
||||
from .database import ChangeSet, write, try_read
|
||||
from .sections import *
|
||||
from .s1_title import inp_in_title_new
|
||||
from .s2_junctions import inp_in_junction_new
|
||||
@@ -8,6 +8,9 @@ from .s4_tanks import inp_in_tank_new
|
||||
from .s5_pipes import inp_in_pipe_new
|
||||
from .s6_pumps import inp_in_pump_new
|
||||
from .s7_valves import inp_in_valve_new
|
||||
from .s8_tags import inp_in_tag_new
|
||||
from .s9_demands import inp_in_demand_new
|
||||
from .s10_status import inp_in_status_new
|
||||
from .s11_patterns import inp_in_pattern_new
|
||||
from .s12_curves import inp_in_curve_new
|
||||
from .s13_controls import inp_in_control_new
|
||||
@@ -28,9 +31,9 @@ _handler = {
|
||||
PIPES : (_L, inp_in_pipe_new),
|
||||
PUMPS : (_L, inp_in_pump_new),
|
||||
VALVES : (_L, inp_in_valve_new),
|
||||
TAGS : (_L, None),
|
||||
DEMANDS : (_L, None),
|
||||
STATUS : (_L, None),
|
||||
TAGS : (_L, inp_in_tag_new),
|
||||
DEMANDS : (_L, inp_in_demand_new),
|
||||
STATUS : (_L, inp_in_status_new),
|
||||
PATTERNS : (_L, inp_in_pattern_new),
|
||||
CURVES : (_L, inp_in_curve_new),
|
||||
CONTROLS : (_L, inp_in_control_new),
|
||||
@@ -128,6 +131,7 @@ def parse_file(project: str, inp: str) -> None:
|
||||
|
||||
pattern_desc_line = None
|
||||
curve_type_desc_line = None
|
||||
demand_junction = None
|
||||
|
||||
with open(inp) as f:
|
||||
for s in levels:
|
||||
@@ -146,8 +150,10 @@ def parse_file(project: str, inp: str) -> None:
|
||||
break
|
||||
|
||||
line = line.strip()
|
||||
if line == '' or line.startswith('['):
|
||||
if line.startswith('['):
|
||||
break
|
||||
elif line == '':
|
||||
continue
|
||||
|
||||
if is_s:
|
||||
sections[s].append(line)
|
||||
@@ -171,6 +177,13 @@ def parse_file(project: str, inp: str) -> None:
|
||||
tokens = line.split()
|
||||
write(project, f"insert into _curve (id, type) values ('{tokens[0]}', '{type_and_desc[0].strip()}');")
|
||||
curve_type_desc_line = None
|
||||
elif s == DEMANDS:
|
||||
tokens = line.split()
|
||||
junction = str(tokens[0])
|
||||
if demand_junction != junction:
|
||||
if try_read(project, f"select * from demands where junction = '{junction}'") != None:
|
||||
write(project, f"delete from demands where junction = '{junction}';")
|
||||
demand_junction = junction
|
||||
|
||||
if handler != None:
|
||||
handler(project, line)
|
||||
|
||||
Reference in New Issue
Block a user