Accept Merge Request #95: (api -> master)
Merge Request: Refactor parser Created By: @王琼钰 Accepted By: @王琼钰 URL: https://tjwater.coding.net/p/tjwatercloud/d/TJWaterServer/git/merge/95
This commit is contained in:
@@ -38,7 +38,7 @@ section_name = ['TITLE', 'JUNCTIONS', 'RESERVOIRS', 'TANKS', 'PIPES',
|
|||||||
'TIMES', 'REPORT', 'OPTIONS', 'COORDINATES', 'VERTICES',
|
'TIMES', 'REPORT', 'OPTIONS', 'COORDINATES', 'VERTICES',
|
||||||
'LABELS', 'BACKDROP', 'END']
|
'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]] = {}
|
file: dict[str, list[str]] = {}
|
||||||
for s in section_name:
|
for s in section_name:
|
||||||
file[s] = []
|
file[s] = []
|
||||||
@@ -71,8 +71,8 @@ def parse_inp(inp: str) -> dict[str, list[str]]:
|
|||||||
return file
|
return file
|
||||||
|
|
||||||
|
|
||||||
def read_inp(project: str, inp: str):
|
def _read_inp(inp: str) -> ChangeSet:
|
||||||
file = parse_inp(inp)
|
file = _parse_inp(inp)
|
||||||
|
|
||||||
file_cs: dict[str, ChangeSet] = {}
|
file_cs: dict[str, ChangeSet] = {}
|
||||||
for s in section_name:
|
for s in section_name:
|
||||||
@@ -205,6 +205,10 @@ def read_inp(project: str, inp: str):
|
|||||||
for s in priorities:
|
for s in priorities:
|
||||||
cs.merge(file_cs[s])
|
cs.merge(file_cs[s])
|
||||||
|
|
||||||
|
return cs
|
||||||
|
|
||||||
|
|
||||||
|
def read_inp(project: str, inp: str):
|
||||||
if is_project_open(project):
|
if is_project_open(project):
|
||||||
close_project(project)
|
close_project(project)
|
||||||
|
|
||||||
@@ -214,7 +218,7 @@ def read_inp(project: str, inp: str):
|
|||||||
create_project(project)
|
create_project(project)
|
||||||
open_project(project)
|
open_project(project)
|
||||||
|
|
||||||
execute_batch_commands(project, cs)
|
execute_batch_command(project, _read_inp(inp))
|
||||||
|
|
||||||
|
|
||||||
def dump_inp(project: str, inp: str):
|
def dump_inp(project: str, inp: str):
|
||||||
|
|||||||
@@ -112,7 +112,9 @@ def inp_in_option(section: list[str]) -> ChangeSet:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
tokens = s.strip().split()
|
tokens = s.strip().split()
|
||||||
if tokens[0].upper() == 'QUALITY':
|
if tokens[0].upper() == 'PATTERN':
|
||||||
|
cs |= { 'PATTERN' : tokens[1] }
|
||||||
|
elif tokens[0].upper() == 'QUALITY':
|
||||||
value = tokens[1]
|
value = tokens[1]
|
||||||
if len(tokens) > 2:
|
if len(tokens) > 2:
|
||||||
value += f' {tokens[2]}'
|
value += f' {tokens[2]}'
|
||||||
|
|||||||
Reference in New Issue
Block a user