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

@@ -152,6 +152,29 @@ def inp_in_junction(section: list[str]) -> ChangeSet:
return cs
def inp_in_junction_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])
elevation = float(tokens[1])
demand = float(tokens[2]) if num_without_desc >= 3 else None
pattern = str(tokens[3]) if num_without_desc >= 4 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}', 'junction');")
write(name, f"insert into junctions (id, elevation) values ('{id}', {elevation});")
write(name, f"insert into demands (junction, demand, pattern) values ('{id}', {demand}, {pattern});")
def inp_out_junction(name: str) -> list[str]:
lines = []
objs = read_all(name, 'select * from junctions')