Accept Merge Request #89: (api -> master)
Merge Request: Prioritize section parser Created By: @王琼钰 Accepted By: @王琼钰 URL: https://tjwater.coding.net/p/tjwatercloud/d/TJWaterServer/git/merge/89
This commit is contained in:
@@ -171,11 +171,37 @@ def read_inp(project: str, inp: str):
|
|||||||
pass # :)
|
pass # :)
|
||||||
|
|
||||||
cs = ChangeSet()
|
cs = ChangeSet()
|
||||||
cs.merge(file_cs['PATTERNS'])
|
priorities = [
|
||||||
cs.merge(file_cs['CURVES'])
|
'PATTERNS',
|
||||||
for s in section_name:
|
'CURVES',
|
||||||
if s == 'PATTERNS' or s == 'CURVES':
|
'JUNCTIONS',
|
||||||
continue
|
'RESERVOIRS',
|
||||||
|
'TANKS',
|
||||||
|
'COORDINATES',
|
||||||
|
'PIPES',
|
||||||
|
'PUMPS',
|
||||||
|
'VALVES',
|
||||||
|
'DEMANDS',
|
||||||
|
'STATUS',
|
||||||
|
'OPTIONS',
|
||||||
|
'TIMES',
|
||||||
|
'EMITTERS',
|
||||||
|
'QUALITY',
|
||||||
|
'SOURCES',
|
||||||
|
'REACTIONS',
|
||||||
|
'MIXING',
|
||||||
|
'ENERGY',
|
||||||
|
'REPORT',
|
||||||
|
'VERTICES',
|
||||||
|
'CONTROLS',
|
||||||
|
'RULES',
|
||||||
|
'TITLE',
|
||||||
|
'TAGS',
|
||||||
|
'LABELS',
|
||||||
|
'BACKDROP',
|
||||||
|
'END',
|
||||||
|
]
|
||||||
|
for s in priorities:
|
||||||
cs.merge(file_cs[s])
|
cs.merge(file_cs[s])
|
||||||
|
|
||||||
if is_project_open(project):
|
if is_project_open(project):
|
||||||
@@ -187,7 +213,7 @@ def read_inp(project: str, inp: str):
|
|||||||
create_project(project)
|
create_project(project)
|
||||||
open_project(project)
|
open_project(project)
|
||||||
|
|
||||||
execute_batch_command(project, cs)
|
execute_batch_commands(project, cs)
|
||||||
|
|
||||||
|
|
||||||
def dump_inp(name: str, inp: str):
|
def dump_inp(name: str, inp: str):
|
||||||
|
|||||||
@@ -271,8 +271,11 @@ def execute_delete_command(name: str, cs: ChangeSet) -> ChangeSet:
|
|||||||
def execute_batch_commands(name: str, cs: ChangeSet) -> ChangeSet:
|
def execute_batch_commands(name: str, cs: ChangeSet) -> ChangeSet:
|
||||||
result = ChangeSet()
|
result = ChangeSet()
|
||||||
|
|
||||||
|
todo = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for op in cs.operations:
|
for op in cs.operations:
|
||||||
|
todo = op
|
||||||
operation = op['operation']
|
operation = op['operation']
|
||||||
if operation == API_ADD:
|
if operation == API_ADD:
|
||||||
result.merge(execute_add_command(name, ChangeSet(op)))
|
result.merge(execute_add_command(name, ChangeSet(op)))
|
||||||
@@ -281,6 +284,7 @@ def execute_batch_commands(name: str, cs: ChangeSet) -> ChangeSet:
|
|||||||
elif operation == API_DELETE:
|
elif operation == API_DELETE:
|
||||||
result.merge(execute_delete_command(name, ChangeSet(op)))
|
result.merge(execute_delete_command(name, ChangeSet(op)))
|
||||||
except:
|
except:
|
||||||
|
print(f'ERROR: Fail to execute {todo}!')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user