mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-16 03:54:27 +05:00
fix: update scp integration for more robust config handling (#535)
* chore: remove scp * Squashed 'kiauh/core/submodules/simple_config_parser/' content from commit abee21c git-subtree-dir: kiauh/core/submodules/simple_config_parser git-subtree-split: abee21c08658be4529028844304df60650c09afa * Squashed 'kiauh/core/submodules/simple_config_parser/' changes from abee21c..aa0302b aa0302b fix: fix missing newline chars in raw strings git-subtree-dir: kiauh/core/submodules/simple_config_parser git-subtree-split: aa0302b02b56b252ed88fd2db88ee878a5bb7b5b * Squashed 'kiauh/core/submodules/simple_config_parser/' changes from aa0302b..ef52958 ef52958 refactor: conditionally add empty line when adding new section git-subtree-dir: kiauh/core/submodules/simple_config_parser git-subtree-split: ef529580f469ef020135cb03e250fcd4e0d70acf * fix: update scp integration for more robust cfg modification Signed-off-by: Dominik Willner <th33xitus@gmail.com> --------- Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -35,7 +35,7 @@ def add_config_section(
|
||||
continue
|
||||
|
||||
scp = SimpleConfigParser()
|
||||
scp.read(cfg_file)
|
||||
scp.read_file(cfg_file)
|
||||
if scp.has_section(section):
|
||||
Logger.print_info("Section already exist. Skipped ...")
|
||||
continue
|
||||
@@ -44,9 +44,9 @@ def add_config_section(
|
||||
|
||||
if options is not None:
|
||||
for option in reversed(options):
|
||||
scp.set(section, option[0], option[1])
|
||||
scp.set_option(section, option[0], option[1])
|
||||
|
||||
scp.write(cfg_file)
|
||||
scp.write_file(cfg_file)
|
||||
|
||||
|
||||
def add_config_section_at_top(section: str, instances: List[InstanceType]) -> None:
|
||||
@@ -55,9 +55,9 @@ def add_config_section_at_top(section: str, instances: List[InstanceType]) -> No
|
||||
tmp_cfg = tempfile.NamedTemporaryFile(mode="w", delete=False)
|
||||
tmp_cfg_path = Path(tmp_cfg.name)
|
||||
scp = SimpleConfigParser()
|
||||
scp.read(tmp_cfg_path)
|
||||
scp.read_file(tmp_cfg_path)
|
||||
scp.add_section(section)
|
||||
scp.write(tmp_cfg_path)
|
||||
scp.write_file(tmp_cfg_path)
|
||||
tmp_cfg.close()
|
||||
|
||||
cfg_file = instance.cfg_file
|
||||
@@ -80,10 +80,10 @@ def remove_config_section(section: str, instances: List[InstanceType]) -> None:
|
||||
continue
|
||||
|
||||
scp = SimpleConfigParser()
|
||||
scp.read(cfg_file)
|
||||
scp.read_file(cfg_file)
|
||||
if not scp.has_section(section):
|
||||
Logger.print_info("Section does not exist. Skipped ...")
|
||||
continue
|
||||
|
||||
scp.remove_section(section)
|
||||
scp.write(cfg_file)
|
||||
scp.write_file(cfg_file)
|
||||
|
||||
Reference in New Issue
Block a user