Start new parser
This commit is contained in:
141
api/inp_in_new.py
Normal file
141
api/inp_in_new.py
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
from .project import *
|
||||||
|
from .database import ChangeSet, get_current_operation, set_restore_operation
|
||||||
|
from .sections import section_name
|
||||||
|
|
||||||
|
|
||||||
|
def parse_inp(project: str, inp: str) -> None:
|
||||||
|
section = ''
|
||||||
|
|
||||||
|
for line in open(inp):
|
||||||
|
line = line.strip()
|
||||||
|
|
||||||
|
if line == '':
|
||||||
|
if section == 'CONTROLS' or section == 'RULES':
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
section = ''
|
||||||
|
continue
|
||||||
|
|
||||||
|
if line.startswith('['):
|
||||||
|
is_section = False
|
||||||
|
for s in section_name:
|
||||||
|
if line.startswith(f'[{s}'):
|
||||||
|
section = s
|
||||||
|
is_section = True
|
||||||
|
break
|
||||||
|
if is_section:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if section == 'TITLE':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'JUNCTIONS': # + coords
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'RESERVOIRS': # + coords
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'TANKS': # + coords
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'PIPES':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'PUMPS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'VALVES':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'TAGS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'DEMANDS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'STATUS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'PATTERNS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'CURVES':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'CONTROLS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'RULES':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'ENERGY':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'EMITTERS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'QUALITY':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'SOURCES':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'REACTIONS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'MIXING':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'TIMES':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'REPORT':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'OPTIONS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'COORDINATES':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'VERTICES':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'LABELS':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'BACKDROP':
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif section == 'END':
|
||||||
|
pass # :)
|
||||||
|
|
||||||
|
|
||||||
|
def read_inp(project: str, inp: str) -> bool:
|
||||||
|
if is_project_open(project):
|
||||||
|
close_project(project)
|
||||||
|
|
||||||
|
if have_project(project):
|
||||||
|
delete_project(project)
|
||||||
|
|
||||||
|
create_project(project)
|
||||||
|
open_project(project)
|
||||||
|
|
||||||
|
close_project(project)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def import_inp(project: str, cs: ChangeSet) -> bool:
|
||||||
|
if is_project_open(project):
|
||||||
|
close_project(project)
|
||||||
|
|
||||||
|
if have_project(project):
|
||||||
|
delete_project(project)
|
||||||
|
|
||||||
|
create_project(project)
|
||||||
|
open_project(project)
|
||||||
|
|
||||||
|
close_project(project)
|
||||||
|
|
||||||
|
return True
|
||||||
Reference in New Issue
Block a user