Support inp in quality, source, reaction, mixing

This commit is contained in:
WQY\qiong
2023-03-16 00:02:11 +08:00
parent b35fccad49
commit bf1aeff1fa
6 changed files with 76 additions and 8 deletions

View File

@@ -131,6 +131,23 @@ def inp_in_source(section: list[str]) -> ChangeSet:
return cs
def inp_in_source_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
node = str(tokens[0])
s_type = str(tokens[1].upper())
strength = float(tokens[2])
pattern = str(tokens[3]) if num_without_desc >= 4 else None
pattern = f"'{pattern}'" if pattern != None else 'null'
write(name, f"insert into sources (node, type, strength, pattern) values ('{node}', '{s_type}', {strength}, {pattern});")
def inp_out_source(name: str) -> list[str]:
lines = []
objs = read_all(name, 'select * from sources')