From cd11167fda4d888b3fd275a5a62d80bf98247137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Thu, 20 Jan 2022 10:20:57 +0100 Subject: [PATCH] Instance.save_config --- kiwi_scp/commands/cmd_init.py | 4 +--- kiwi_scp/instance.py | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/kiwi_scp/commands/cmd_init.py b/kiwi_scp/commands/cmd_init.py index a93d565..a5ae22d 100644 --- a/kiwi_scp/commands/cmd_init.py +++ b/kiwi_scp/commands/cmd_init.py @@ -68,6 +68,4 @@ class InitCommand(KiwiCommand): os.mkdir(instance.directory) # write out the new kiwi.yml - cfg = KiwiConfig.parse_obj(kiwi_dict) - with open(instance.directory.joinpath(KIWI_CONF_NAME), "w") as file: - cfg.dump_kiwi_yml(file) + instance.save_config(KiwiConfig.parse_obj(kiwi_dict)) diff --git a/kiwi_scp/instance.py b/kiwi_scp/instance.py index 30389e7..9f41977 100644 --- a/kiwi_scp/instance.py +++ b/kiwi_scp/instance.py @@ -3,6 +3,7 @@ from typing import Generator, Dict, Sequence import attr +from ._constants import KIWI_CONF_NAME from .config import KiwiConfig from .project import Project @@ -17,6 +18,10 @@ class Instance: return KiwiConfig.from_directory(self.directory) + def save_config(self, config: KiwiConfig) -> None: + with open(self.directory.joinpath(KIWI_CONF_NAME), "w") as file: + config.dump_kiwi_yml(file) + @property def projects(self) -> Generator[Project, None, None]: for project in self.config.projects: