From 2e5f2d8d0b469745d4f4922a7fa6ee96a8b94b2b Mon Sep 17 00:00:00 2001 From: "WQY\\qiong" Date: Fri, 18 Nov 2022 21:27:11 +0800 Subject: [PATCH 1/3] Rename inp file --- inp/{3_BWSN_Network_2.inp => BWSN.inp} | 0 inp/{4乡镇综合.inp => 乡镇综合.inp} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename inp/{3_BWSN_Network_2.inp => BWSN.inp} (100%) rename inp/{4乡镇综合.inp => 乡镇综合.inp} (100%) diff --git a/inp/3_BWSN_Network_2.inp b/inp/BWSN.inp similarity index 100% rename from inp/3_BWSN_Network_2.inp rename to inp/BWSN.inp diff --git a/inp/4乡镇综合.inp b/inp/乡镇综合.inp similarity index 100% rename from inp/4乡镇综合.inp rename to inp/乡镇综合.inp From 7a1462e547fb8ab718c490e798748ba911cfe19e Mon Sep 17 00:00:00 2001 From: "WQY\\qiong" Date: Fri, 18 Nov 2022 21:58:34 +0800 Subject: [PATCH 2/3] Add error log --- api/command.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/command.py b/api/command.py index e48a732..82d72fb 100644 --- a/api/command.py +++ b/api/command.py @@ -271,8 +271,11 @@ def execute_delete_command(name: str, cs: ChangeSet) -> ChangeSet: def execute_batch_commands(name: str, cs: ChangeSet) -> ChangeSet: result = ChangeSet() + todo = {} + try: for op in cs.operations: + todo = op operation = op['operation'] if operation == API_ADD: 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: result.merge(execute_delete_command(name, ChangeSet(op))) except: + print(f'ERROR: Fail to execute {todo}!') pass return result From 53ffcb6e0fbfb651d606ce5e5e873c7f60d523b6 Mon Sep 17 00:00:00 2001 From: "WQY\\qiong" Date: Fri, 18 Nov 2022 21:58:58 +0800 Subject: [PATCH 3/3] Prioritize section parser --- api/api_parser.py | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/api/api_parser.py b/api/api_parser.py index edd4afb..ad9fb51 100644 --- a/api/api_parser.py +++ b/api/api_parser.py @@ -171,11 +171,37 @@ def read_inp(project: str, inp: str): pass # :) cs = ChangeSet() - cs.merge(file_cs['PATTERNS']) - cs.merge(file_cs['CURVES']) - for s in section_name: - if s == 'PATTERNS' or s == 'CURVES': - continue + priorities = [ + 'PATTERNS', + 'CURVES', + 'JUNCTIONS', + '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]) if is_project_open(project): @@ -187,7 +213,7 @@ def read_inp(project: str, inp: str): create_project(project) open_project(project) - execute_batch_command(project, cs) + execute_batch_commands(project, cs) def dump_inp(name: str, inp: str):