diff --git a/api/s13_controls.py b/api/s13_controls.py index e052033..3ba7b45 100644 --- a/api/s13_controls.py +++ b/api/s13_controls.py @@ -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]: diff --git a/api/s14_rules.py b/api/s14_rules.py index 848c8fd..381003b 100644 --- a/api/s14_rules.py +++ b/api/s14_rules.py @@ -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]: diff --git a/api/s19_reactions.py b/api/s19_reactions.py index f48c8d8..a7bd4b7 100644 --- a/api/s19_reactions.py +++ b/api/s19_reactions.py @@ -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() diff --git a/api/s21_times.py b/api/s21_times.py index 2631cb9..26eaf15 100644 --- a/api/s21_times.py +++ b/api/s21_times.py @@ -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]: diff --git a/api/s23_options.py b/api/s23_options.py index cb388da..5e3fed5 100644 --- a/api/s23_options.py +++ b/api/s23_options.py @@ -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]: diff --git a/api/s27_backdrop.py b/api/s27_backdrop.py index 1e1d3cb..030eb81 100644 --- a/api/s27_backdrop.py +++ b/api/s27_backdrop.py @@ -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]: