Refactor parser
This commit is contained in:
@@ -38,7 +38,7 @@ section_name = ['TITLE', 'JUNCTIONS', 'RESERVOIRS', 'TANKS', 'PIPES',
|
||||
'TIMES', 'REPORT', 'OPTIONS', 'COORDINATES', 'VERTICES',
|
||||
'LABELS', 'BACKDROP', 'END']
|
||||
|
||||
def parse_inp(inp: str) -> dict[str, list[str]]:
|
||||
def _parse_inp(inp: str) -> dict[str, list[str]]:
|
||||
file: dict[str, list[str]] = {}
|
||||
for s in section_name:
|
||||
file[s] = []
|
||||
@@ -71,8 +71,8 @@ def parse_inp(inp: str) -> dict[str, list[str]]:
|
||||
return file
|
||||
|
||||
|
||||
def read_inp(project: str, inp: str):
|
||||
file = parse_inp(inp)
|
||||
def _read_inp(inp: str) -> ChangeSet:
|
||||
file = _parse_inp(inp)
|
||||
|
||||
file_cs: dict[str, ChangeSet] = {}
|
||||
for s in section_name:
|
||||
@@ -205,6 +205,10 @@ def read_inp(project: str, inp: str):
|
||||
for s in priorities:
|
||||
cs.merge(file_cs[s])
|
||||
|
||||
return cs
|
||||
|
||||
|
||||
def read_inp(project: str, inp: str):
|
||||
if is_project_open(project):
|
||||
close_project(project)
|
||||
|
||||
@@ -214,7 +218,7 @@ def read_inp(project: str, inp: str):
|
||||
create_project(project)
|
||||
open_project(project)
|
||||
|
||||
execute_batch_commands(project, cs)
|
||||
execute_batch_command(project, _read_inp(inp))
|
||||
|
||||
|
||||
def dump_inp(project: str, inp: str):
|
||||
|
||||
Reference in New Issue
Block a user