Support inp in tag, demand, status

This commit is contained in:
WQY\qiong
2023-03-15 22:34:38 +08:00
parent 617c66d0cd
commit f79a9cdae8
4 changed files with 67 additions and 5 deletions

View File

@@ -97,6 +97,23 @@ def inp_in_demand(section: list[str]) -> ChangeSet:
return cs
def inp_in_demand_new(name: str, line: str) -> None:
tokens = line.split()
num = len(tokens)
has_desc = tokens[-1].startswith(';')
num_without_desc = (num - 1) if has_desc else num
junction = str(tokens[0])
demand = float(tokens[1])
pattern = str(tokens[2]) if num_without_desc >= 3 else None
pattern = f"'{pattern}'" if pattern != None else 'null'
category = str(tokens[3]) if num_without_desc >= 4 else None
category = f"'{category}'" if category != None else 'null'
write(name, f"\ninsert into demands (junction, demand, pattern, category) values ('{junction}', {demand}, {pattern}, {category});")
def inp_out_demand(name: str) -> list[str]:
lines = []
objs = read_all(name, f"select * from demands order by _order")