Second pass scan

This commit is contained in:
WQY\qiong
2023-03-09 23:24:41 +08:00
parent 55febbe163
commit e41abe362f
3 changed files with 71 additions and 0 deletions

View File

@@ -145,6 +145,27 @@ def inp_in_reservoir(section: list[str]) -> ChangeSet:
return cs
def inp_in_reservoir_new(name: str, line: str) -> None:
# skip comment
if line.startswith(';'):
return
tokens = line.split()
num = len(tokens)
has_desc = tokens[-1].startswith(';')
num_without_desc = (num - 1) if has_desc else num
id = str(tokens[0])
head = float(tokens[1])
pattern = str(tokens[2]) if num_without_desc >= 3 else None
pattern = f"'{pattern}'" if pattern != None else 'null'
desc = str(tokens[-1]) if has_desc else None
write(name, f"insert into _node (id, type) values ('{id}', 'reservoir');")
write(name, f"\ninsert into reservoirs (id, head, pattern) values ('{id}', {head}, {pattern});")
def inp_out_reservoir(name: str) -> list[str]:
lines = []
objs = read_all(name, 'select * from reservoirs')