Fix reading inp bug
This commit is contained in:
@@ -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]:
|
||||
|
||||
@@ -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]:
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -68,17 +68,19 @@ def set_time(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
|
||||
def inp_in_time(section: list[str]) -> ChangeSet:
|
||||
cs = g_update_prefix | { 'type' : 'time' }
|
||||
for s in section:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
|
||||
line = s.upper().strip()
|
||||
for key in get_time_schema('').keys():
|
||||
if line.startswith(key):
|
||||
value = line.removeprefix(key).strip()
|
||||
cs |= { key : value }
|
||||
return ChangeSet(cs)
|
||||
if len(section) > 0:
|
||||
cs = g_update_prefix | { 'type' : 'time' }
|
||||
for s in section:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
|
||||
line = s.upper().strip()
|
||||
for key in get_time_schema('').keys():
|
||||
if line.startswith(key):
|
||||
value = line.removeprefix(key).strip()
|
||||
cs |= { key : value }
|
||||
return ChangeSet(cs)
|
||||
return ChangeSet()
|
||||
|
||||
|
||||
def inp_out_time(name: str) -> list[str]:
|
||||
|
||||
@@ -106,26 +106,28 @@ def set_option(name: str, cs: ChangeSet) -> ChangeSet:
|
||||
|
||||
|
||||
def inp_in_option(section: list[str]) -> ChangeSet:
|
||||
cs = g_update_prefix | { 'type' : 'option' }
|
||||
for s in section:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
if len(section) > 0:
|
||||
cs = g_update_prefix | { 'type' : 'option' }
|
||||
for s in section:
|
||||
if s.startswith(';'):
|
||||
continue
|
||||
|
||||
tokens = s.strip().split()
|
||||
if tokens[0].upper() == 'PATTERN':
|
||||
cs |= { 'PATTERN' : tokens[1] }
|
||||
elif tokens[0].upper() == 'QUALITY':
|
||||
value = tokens[1]
|
||||
if len(tokens) > 2:
|
||||
value += f' {tokens[2]}'
|
||||
cs |= { 'QUALITY' : value }
|
||||
else:
|
||||
line = s.upper().strip()
|
||||
for key in get_option_schema('').keys():
|
||||
if line.startswith(key):
|
||||
value = line.removeprefix(key).strip()
|
||||
cs |= { key : value }
|
||||
return ChangeSet(cs)
|
||||
tokens = s.strip().split()
|
||||
if tokens[0].upper() == 'PATTERN':
|
||||
cs |= { 'PATTERN' : tokens[1] }
|
||||
elif tokens[0].upper() == 'QUALITY':
|
||||
value = tokens[1]
|
||||
if len(tokens) > 2:
|
||||
value += f' {tokens[2]}'
|
||||
cs |= { 'QUALITY' : value }
|
||||
else:
|
||||
line = s.upper().strip()
|
||||
for key in get_option_schema('').keys():
|
||||
if line.startswith(key):
|
||||
value = line.removeprefix(key).strip()
|
||||
cs |= { key : value }
|
||||
return ChangeSet(cs)
|
||||
return ChangeSet()
|
||||
|
||||
|
||||
def inp_out_option(name: str) -> list[str]:
|
||||
|
||||
@@ -32,9 +32,10 @@ class InpBackdrop:
|
||||
|
||||
|
||||
def inp_in_backdrop(section: list[str]) -> ChangeSet:
|
||||
obj = InpBackdrop(section)
|
||||
cs = ChangeSet(g_update_prefix | {'type': 'backdrop', 'content' : obj.value})
|
||||
return cs
|
||||
if len(section) > 0:
|
||||
obj = InpBackdrop(section)
|
||||
return ChangeSet(g_update_prefix | {'type': 'backdrop', 'content' : obj.value})
|
||||
return ChangeSet()
|
||||
|
||||
|
||||
def inp_out_backdrop(name: str) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user