diff --git a/api/s21_times.py b/api/s21_times.py index e3f6398..848ba9c 100644 --- a/api/s21_times.py +++ b/api/s21_times.py @@ -69,10 +69,9 @@ def set_time(name: str, cs: ChangeSet) -> ChangeSet: def inp_in_time(section: list[str]) -> ChangeSet: cs = g_update_prefix | { 'type' : 'time' } - keys = ['DURATION', 'HYDRAULIC TIMESTEP', 'QUALITY TIMESTEP', 'RULE TIMESTEP', 'PATTERN TIMESTEP', 'PATTERN START', 'REPORT TIMESTEP', 'REPORT START', 'START CLOCKTIME', 'STATISTIC'] for s in section: line = s.upper().strip() - for key in keys: + for key in get_time_schema('').keys(): if line.startswith(key): value = line.removeprefix(key).strip() cs |= { key : value } diff --git a/api/s23_options.py b/api/s23_options.py index 928379e..5d77569 100644 --- a/api/s23_options.py +++ b/api/s23_options.py @@ -103,3 +103,24 @@ def set_option_cache(name: str, cs: ChangeSet) -> SqlChangeSet: def set_option(name: str, cs: ChangeSet) -> ChangeSet: return execute_command(name, set_option_cache(name, cs)) + + +def inp_in_option(section: list[str]) -> ChangeSet: + cs = g_update_prefix | { 'type' : 'option' } + for s in section: + 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) + + +def inp_out_option(name: str) -> list[str]: + lines = [] + objs = read_all(name, f"select * from options") + for obj in objs: + key = obj['key'] + value = obj['value'] + lines.append(f'{key} {value}') + return lines