Fix reading inp bug

This commit is contained in:
WQY\qiong
2023-02-09 00:08:36 +08:00
parent 7f9c9a8e8c
commit 8979885eac
6 changed files with 45 additions and 38 deletions

View File

@@ -35,8 +35,9 @@ def set_control(name: str, cs: ChangeSet) -> ChangeSet:
def inp_in_control(section: list[str]) -> ChangeSet:
cs = ChangeSet(g_update_prefix | {'type': 'control', 'controls' : section})
return cs
if len(section) > 0:
return ChangeSet(g_update_prefix | {'type': 'control', 'controls' : section})
return ChangeSet()
def inp_out_control(name: str) -> list[str]:

View File

@@ -35,8 +35,9 @@ def set_rule(name: str, cs: ChangeSet) -> ChangeSet:
def inp_in_rule(section: list[str]) -> ChangeSet:
cs = ChangeSet(g_update_prefix | {'type': 'rule', 'rules' : section})
return cs
if len(section) > 0:
return ChangeSet(g_update_prefix | {'type': 'rule', 'rules' : section})
return ChangeSet()
def inp_out_rule(name: str) -> list[str]:

View File

@@ -199,7 +199,7 @@ def inp_in_reaction(section: list[str]) -> ChangeSet:
elif token0 == 'TANK':
tank = tokens[1]
value = tokens[2]
cs.append(g_update_prefix | { 'type' : 'pipe_reaction', 'tank' : tank, 'value': value })
cs.append(g_update_prefix | { 'type' : 'tank_reaction', 'tank' : tank, 'value': value })
else:
line = s.upper().strip()

View File

@@ -68,6 +68,7 @@ def set_time(name: str, cs: ChangeSet) -> ChangeSet:
def inp_in_time(section: list[str]) -> ChangeSet:
if len(section) > 0:
cs = g_update_prefix | { 'type' : 'time' }
for s in section:
if s.startswith(';'):
@@ -79,6 +80,7 @@ def inp_in_time(section: list[str]) -> ChangeSet:
value = line.removeprefix(key).strip()
cs |= { key : value }
return ChangeSet(cs)
return ChangeSet()
def inp_out_time(name: str) -> list[str]:

View File

@@ -106,6 +106,7 @@ def set_option(name: str, cs: ChangeSet) -> ChangeSet:
def inp_in_option(section: list[str]) -> ChangeSet:
if len(section) > 0:
cs = g_update_prefix | { 'type' : 'option' }
for s in section:
if s.startswith(';'):
@@ -126,6 +127,7 @@ def inp_in_option(section: list[str]) -> ChangeSet:
value = line.removeprefix(key).strip()
cs |= { key : value }
return ChangeSet(cs)
return ChangeSet()
def inp_out_option(name: str) -> list[str]:

View File

@@ -32,9 +32,10 @@ class InpBackdrop:
def inp_in_backdrop(section: list[str]) -> ChangeSet:
if len(section) > 0:
obj = InpBackdrop(section)
cs = ChangeSet(g_update_prefix | {'type': 'backdrop', 'content' : obj.value})
return cs
return ChangeSet(g_update_prefix | {'type': 'backdrop', 'content' : obj.value})
return ChangeSet()
def inp_out_backdrop(name: str) -> list[str]: