Support inp in energy, emitter

This commit is contained in:
WQY\qiong
2023-03-15 23:47:06 +08:00
parent f79a9cdae8
commit b35fccad49
4 changed files with 47 additions and 3 deletions

View File

@@ -169,6 +169,35 @@ def inp_in_energy(section: list[str]) -> ChangeSet:
return cs
def inp_in_energy_new(name: str, line: str) -> None:
tokens = line.split()
if tokens[0].upper() == 'PUMP':
pump = tokens[1]
key = tokens[2].lower()
value = tokens[3]
if key == 'price':
value = float(value)
else:
value = f"'{value}'"
if key == 'efficiency':
key = 'effic'
write(name, f"insert into energy_pump_{key} (pump, {key}) values ('{pump}', {value});")
else:
line = line.upper().strip()
for key in get_energy_schema('').keys():
if line.startswith(key):
value = line.removeprefix(key).strip()
# exception here
if line.startswith('GLOBAL EFFICIENCY'):
value = line.removeprefix('GLOBAL EFFICIENCY').strip()
write(name, f"update energy set value = '{value}' where key = '{key}';")
def inp_out_energy(name: str) -> list[str]:
lines = []