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',
|
||||
'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):
|
||||
|
||||
@@ -112,7 +112,9 @@ def inp_in_option(section: list[str]) -> ChangeSet:
|
||||
continue
|
||||
|
||||
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]
|
||||
if len(tokens) > 2:
|
||||
value += f' {tokens[2]}'
|
||||
|
||||
Reference in New Issue
Block a user