refine
This commit is contained in:
@@ -31,6 +31,7 @@ from .s24_coordinates import inp_in_coord
|
||||
from .s25_vertices import inp_in_vertex
|
||||
from .s26_labels import inp_in_label
|
||||
from .s27_backdrop import inp_in_backdrop
|
||||
from .s32_region import inp_in_region,inp_in_bound
|
||||
|
||||
_S = 'S'
|
||||
_L = 'L'
|
||||
@@ -64,6 +65,8 @@ _handler = {
|
||||
OPTIONS : (_S, _inp_in_option), # line, version
|
||||
COORDINATES : (_L, inp_in_coord),
|
||||
VERTICES : (_L, inp_in_vertex),
|
||||
REGION : (_L, inp_in_region),
|
||||
BOUND : (_L, inp_in_bound),
|
||||
LABELS : (_L, inp_in_label),
|
||||
BACKDROP : (_S, inp_in_backdrop),
|
||||
#END : 'END',
|
||||
@@ -106,6 +109,8 @@ _level_4 = [
|
||||
ENERGY,
|
||||
REACTIONS,
|
||||
VERTICES,
|
||||
REGION,
|
||||
BOUND,
|
||||
]
|
||||
|
||||
|
||||
@@ -156,7 +161,7 @@ def _get_file_offset(inp: str) -> tuple[dict[str, list[int]], bool]:
|
||||
elif line != '' and line.startswith(';') == False:
|
||||
if current == DEMANDS:
|
||||
demand_outside = True
|
||||
|
||||
|
||||
return (offset, demand_outside)
|
||||
|
||||
|
||||
@@ -180,7 +185,7 @@ def parse_file(project: str, inp: str, version: str = '3') -> None:
|
||||
curve_type_desc_line = None
|
||||
|
||||
sql_batch = SQLBatch(project)
|
||||
|
||||
print("aaa")
|
||||
_print_time("Second scan...")
|
||||
with open(inp) as f:
|
||||
for s in levels:
|
||||
@@ -250,11 +255,14 @@ def parse_file(project: str, inp: str, version: str = '3') -> None:
|
||||
sql_batch.add(f"insert into _curve (id, type) values ('{tokens[0]}', '{type}');")
|
||||
current_curve = tokens[0]
|
||||
curve_type_desc_line = None
|
||||
|
||||
elif s == BOUND:
|
||||
tokens = line.split()
|
||||
if s == JUNCTIONS:
|
||||
sql_batch.add(handler(line, demand_outside))
|
||||
elif s == PATTERNS:
|
||||
sql_batch.add(handler(line, current_pattern not in variable_patterns))
|
||||
elif s==BOUND:
|
||||
continue
|
||||
else:
|
||||
sql_batch.add(handler(line))
|
||||
|
||||
@@ -310,12 +318,12 @@ def import_inp(project: str, cs: ChangeSet, version: str = '3') -> bool:
|
||||
os.remove(filename)
|
||||
|
||||
_print_time(f'Start writing temp file "{filename}"...')
|
||||
with open(filename, 'w') as f:
|
||||
with open(filename, 'w',encoding="GBK") as f:
|
||||
f.write(str(cs.operations[0]['inp']))
|
||||
_print_time(f'End writing temp file "{filename}"...')
|
||||
|
||||
result = read_inp(project, filename, version)
|
||||
|
||||
os.remove(filename)
|
||||
#os.remove(filename)
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user