diff --git a/api/s14_rules.py b/api/s14_rules.py index f8bed6c..e5d1834 100644 --- a/api/s14_rules.py +++ b/api/s14_rules.py @@ -24,3 +24,19 @@ def set_rule_cache(name: str, cs: ChangeSet) -> SqlChangeSet: def set_rule(name: str, cs: ChangeSet) -> ChangeSet: return execute_command(name, set_rule_cache(name, cs)) + + +class InpRule: + def __init__(self, section) -> None: + self.rule = '\n'.join(section) + + +def inp_in_rule(section: list[str]) -> ChangeSet: + obj = InpRule(section) + cs = ChangeSet({'operation' : API_UPDATE, 'type': 'rule', 'rule' : obj.rule}) + return cs + + +def inp_out_rule(name: str) -> list[str]: + obj = str(get_rule(name)['rule']) + return obj.split('\n')