Replace set with list

This commit is contained in:
WQY\qiong
2023-03-15 21:47:46 +08:00
parent 4e6864b2fc
commit 81c4e0308b

View File

@@ -48,7 +48,7 @@ _handler = {
#END : 'END', #END : 'END',
} }
_level_1 = { _level_1 = [
TITLE, TITLE,
PATTERNS, PATTERNS,
CURVES, CURVES,
@@ -58,15 +58,15 @@ _level_1 = {
REPORT, REPORT,
OPTIONS, OPTIONS,
BACKDROP, BACKDROP,
} ]
_level_2 = { _level_2 = [
JUNCTIONS, JUNCTIONS,
RESERVOIRS, RESERVOIRS,
TANKS, TANKS,
} ]
_level_3 = { _level_3 = [
PIPES, PIPES,
PUMPS, PUMPS,
VALVES, VALVES,
@@ -77,15 +77,15 @@ _level_3 = {
MIXING, MIXING,
COORDINATES, COORDINATES,
LABELS, LABELS,
} ]
_level_4 = { _level_4 = [
TAGS, TAGS,
STATUS, STATUS,
ENERGY, ENERGY,
REACTIONS, REACTIONS,
VERTICES, VERTICES,
} ]
_UNKNOWN = 'UNKNOWN' _UNKNOWN = 'UNKNOWN'
@@ -114,9 +114,8 @@ def _get_offset(inp: str) -> dict[str, list[int]]:
def parse_file(project: str, inp: str) -> None: def parse_file(project: str, inp: str) -> None:
offset = _get_offset(inp) offset = _get_offset(inp)
print(offset)
levels = _level_1 | _level_2 | _level_3 | _level_4 levels = _level_1 + _level_2 + _level_3 + _level_4
# parse the whole section rather than line # parse the whole section rather than line
sections : dict[str, list[str]]= {} sections : dict[str, list[str]]= {}
@@ -194,12 +193,14 @@ def read_inp_new(project: str, inp: str) -> bool:
create_project(project) create_project(project)
open_project(project) open_project(project)
try: parse_inp(project, inp)
'''try:
parse_inp(project, inp) parse_inp(project, inp)
except: except:
close_project(project) close_project(project)
delete_project(project) delete_project(project)
return False return False'''
close_project(project) close_project(project)
return True return True